C#编译出错的问题

来源:百度知道 编辑:UC知道 时间:2024/09/19 16:49:30
请大家帮我看看,是哪里出错了,本人为初学C#者,正在自学中:
using System;

namespace TestCSharp1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
public class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
// [STAThread]
public static readonly Color BackColor;

static Class1()
{
DateTime now = DateTime.Now;//当前时间
if (now.DayOfWeek == DayOfWeek.Saturday || now.DayOfWeek == DayOfWeek.Sunday)
{
BackColor = Color.Green;
}else
{
BackColor = Color.Red;
}
}

static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Console.WriteLine(Class1.BackColor.ToString());
}
}
}

编译后出错为:
找不到类型或命名空间名称“Color”(是否缺少using指令或程序集引用?)
关键是我写了uisng System.Drawing这句话后,出现错误:
命名空间并不直接包含诸如字段或方法之类的成员

using System.Drawing

using System;
uisng System.Drawing; //-----这里
....

先加分,我帮你

Color类是.NET FRAMWORK封装的一个类,如果想使用这个类,必须在顶部引用命名空间,using System.Drawing;