标签:read ccf font 静态 color int block 只读 size
1 namespace Test 2 { 3 class Program 4 { 5 static void Main(string[] args) 6 { 7 Test t1 = new Test(); 8 Test t2 = new Test(); 9 } 10 } 11 12 public class Test 13 { 14 public Test() 15 { 16 n = 2; //改变了只读变量n的值 17 } 18 19 readonly int n = 1; 20 } 21 }
如果在编译时已经知道静态只读字段的值,那么它的初始赋值方法将和常量字段非常相似。但是,如果直到运行时才知道静态只读字段的值,就必须使用静态构造函数。
标签:read ccf font 静态 color int block 只读 size
原文地址:http://www.cnblogs.com/gyt-xtt/p/6264701.html