class Test { privatestring strI =""; //聲明一個字段strI /**////<summary> /// 在構造函數中爲strI初始化值 ///</summary> public Test() { strI ="狀態比能力重要"; } /**////<summary> /// 用Run方法返回strI ///</summary> ///<returns></returns> publicstring Run() { return strI; } }
class Program { staticvoid Main(string[] args) { Test T =new Test();//創建對象T的引用爲Test,併爲實例化。 Console.WriteLine(T.Run());//T.Run爲對象T中的方法。 Console.ReadLine(); } }
class Test { privatestring strI =""; //聲明一個字段strI /**////<summary> /// 在構造函數中爲strI初始化值 ///</summary> public Test(string name,string strI) { this.strI = name +"說:"+ strI; } /**////<summary> /// 用Run方法返回strI ///</summary> ///<returns></returns> publicstring Run() { return strI; }
class Program { staticvoid Main(string[] args) { Test T =new Test("×××", "咱們愛咱們的民族,這是咱們自信心的源泉。");//創建對象T的引用爲Test,併爲實例化。 Console.WriteLine(T.Run());//T.Run爲對象T中的方法。 Console.ReadLine(); } }