日期:2014-05-20  浏览次数:20741 次

c#高级编程 里面的例子怎么不对啊?
using   System;
using   System.Collections.Generic;
using   System.Text;
using   System.Drawing;


namespace   ConsoleApplication1
{
      public   class   UserPrefernces
      {
              public   static   readonly   Color   BackColor;

                static     UserPreferences()
                {
                  DateTime   now=DateTime.Now;
                        if(now.DayOfWeek==DayOfWeek.Saturday||now.DayOfWeek==DayOfWeek.Sunday)
                                BackColor=Color.Green;
                        else
                                BackColor=Color.Red;
                }

                private   UserPreferences()
                {
                }
      }
     
  class   MainEntryPoint

        {
               
                static   void   Main(string[]   args)
                {
                      Console.WriteLine( "User-Preferences:   BackColor   is:   "+UserPrefernces.BackColor.ToString());
                }
        }
}      

我这都是照着书写的,但是编译提示说
“类、结构或接口方法必须有返回类型”
无法编译啊,怎么回事???

------解决方案--------------------
拼写错误
你的类名是 UserPrefernces
而构造函数名是 UserPreferences