初始化--代码
public class A{public static int X; //1static A(){X = B.Y + 1; //2 找B.Y時就會執(zhí)行Y=A.X+1;}}public class B{public static int Y = A.X + 1;static B(){}}
調(diào)用A.X ?B.Y,調(diào)用時,幾乎同時執(zhí)行類內(nèi)部的靜態(tài)數(shù)據(jù)成員,結(jié)果X=0,Y=1,再調(diào)用靜態(tài)構(gòu)造函數(shù),X=2
A.X=2,B.Y=1;
public class BaseA{public static MyTest a1 = new MyTest("a1");public MyTest a2 = new MyTest("a2");static BaseA(){MyTest a3 = new MyTest("a3");}public BaseA(){MyTest a4 = new MyTest("a4");}public virtual void MyFun(){MyTest a5 = new MyTest("a5");}}public class BaseB : BaseA{public static MyTest b1 = new MyTest("b1");public MyTest b2 = new MyTest("b2");static BaseB(){MyTest b3 = new MyTest("b3");}public BaseB(){MyTest b4 = new MyTest("b4");}public new void MyFun(){MyTest b5 = new MyTest("b5");}}static class Program{static void Main(){BaseB baseb = new BaseB();baseb.MyFun();Console.Read();}}public class MyTest{public MyTest(string info){Console.WriteLine(info);}}?http://www.cnblogs.com/hkncd/archive/2011/06/05/2073404.html
?字符串反轉(zhuǎn)(不能用string,考的就是StringBuilder)
public static string Reverse(string str){if (string.IsNullOrEmpty(str)){ throw new ArgumentException("參數(shù)不合法");}StringBuilder sb = new StringBuilder(str.Length);for (int index = str.Length - 1; index >= 0; index--){sb.Append(str[index]);}return sb.ToString();}?
public class Hong<T> {public static int count = 0;public Hong() {count++;}public int GetCount(){return count;} }new Hong<string>();new Hong<string>();new Hong<string>();new Hong<bool>();Hong<bool> h = new Hong<bool>();var a = h.GetCount();//2?
轉(zhuǎn)載于:https://www.cnblogs.com/hongdada/archive/2013/03/28/2986771.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
- 上一篇: R语言从入门到精通Day2之【R语言软件
- 下一篇: 软件测试的阶段划分