遇到问题,代码如下
using System;
using System.Drawing;
namespace Wrox.ProCSharp.StaticConstryctorSample
{
public class UserPreferences
{
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: " + UserPreferences.BackColor.ToString());
}
}
}
请问这是怎么回事?谢谢