早教吧 育儿知识 作业答案 考试题库 百科 知识分享

C#的小问题usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Drawing.Color;namespaceConsoleApplication1{classProgram{publicstaticreadonlyColorBackColor;staticProgram(){DateTimenow=DateTime.Now;if(n

题目详情
C#的小问题using System; using System.Collections.Generic; using System.Text; using System.Drawing.Color; namespace ConsoleApplication1 { class Program { public static readonly Color BackColor; static Program() { DateTime now = DateTime.Now; if (now.DayOfWeek = DayOfWeek.Saturday || now.DayOfWeek = DayOfWeek.Sunday) BackColor = Color.Green; else BackColor = Color.Red; } private Program() { } } class Text { public static void Main() { Console.WriteLine(Program.BackColor.ToString()); } } } 错误 1 命名空间“System”中不存在类型或命名空间名称“Drawing”(是缺少程序集引用吗?) C:\Users\user\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 4 14 ConsoleApplication1 错误 2 找不到类型或命名空间名称“Color”(是否缺少 using 指令或程序集引用?) C:\Users\user\AppData\Local\Temporary Projects\ConsoleApplication1\Program.cs 9 32 ConsoleApplication1
▼优质解答
答案和解析
using System; using System.Collections.Generic; using System.Text; using System.Drawing;//here namespace ConsoleApplication1 { class Program { public static readonly Color BackColor; static Program() { DateTime now = DateTime.Now; if (now.DayOfWeek == DayOfWeek.Saturday || now.DayOfWeek == DayOfWeek.Sunday)//here BackColor = Color.Green; else BackColor = Color.Red; } private Program() { } } class Text { public static void Main() { Console.WriteLine(Program.BackColor.ToString()); } } } 修改了2个地方,