VS.NET的帮助是个好东东!// Here we'll create a hashtable of employee numbers and employee names Hashtable table = new Hashtable();// now, we will add elements to the hashtable, as key-value pairs table.Add(5123, "Jay"); table.Add(1829, "Tom"); table.Add(2882, "Matt");
Hashtable table = new Hashtable();// now, we will add elements to the hashtable, as key-value pairs
table.Add(5123, "Jay");
table.Add(1829, "Tom");
table.Add(2882, "Matt");
pirvate static HashTable ht = InitHashtable();public static HashTable InitHashtable(){
HashTable ht =new HashTable();
ht.Add(2882, "Matt");
return ht;
}
[email protected]
那样的话,就要多出一个初始化的步骤,有几个静态的方法都要使用该静态成员,那么是否意味着每次都要检查该成员是否已经初始化过了?或许使用Builder Pattern 在使用前把他们包起来?这样太复杂了,没有实际意义。我只想要一个简单的方法。
InitClass()是不是要返回一个int类型啊!哈哈谢谢!