[C#] 纯文本查看 复制代码
class Program
{
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Green;
//直接使用const值
Console.WriteLine(sample.constValue);
//实例化对象后使用
sample2 s2 = new sample2();
Console.WriteLine(s2.readonlyValue);
Console.Read();
}
class sample
{
public const int constValue = 10;
}
class sample2
{
public readonly int readonlyValue = 20;
}
}