C#之windows桌面软件第十三课:C#中常用的类有哪些?构造函数怎么用?
生活随笔
收集整理的這篇文章主要介紹了
C#之windows桌面软件第十三课:C#中常用的类有哪些?构造函数怎么用?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
C#之windows桌面軟件第十三課:C#中常用的類有哪些?構造函數怎么用?
using System; using System.Collections.Generic; using System.Linq; using System.Text;/*object類*//*TextBox文本控件類*/ /*Button按鈕類*/ /*CheckBox多選框類*/ /*Form窗體類*/ /*label標簽控件類*/ /*GroupBox分組類*/ /*ProgressBar進度條類*/ /*SerialPort串口類*/ /*Timer定時器類*/ /*MessageBox提示框類*/ /*string字符串類*/ /*Convert類型轉換類*/ /*Console輸入輸出流類*/ /*Exception系統異常類*/ /*SystemSounds系統提示音類*/ /*Image圖像類*/ /*Bitmap位圖類*/ /*Process進程類*/ /*Thread線程類*/class Test {public string str;//構造函數1public Test(){}//構造函數2public Test(string Init){str = Init;}} namespace ConsoleApplication1 {class Program{static void Main(string[] args){//Test t = new Test("aaa");//構造函數1Test t1 = new Test();Test t2 = new Test();t1.str = "aaa";t2.str = "bbb";Console.WriteLine(t1.str+ " " + t2.str);//構造函數2string str = "1"; //賦值方式1Test t3 = new Test(str);Console.WriteLine(t3.str);Test t4 = new Test("ccc");//賦值方式2Console.WriteLine(t4.str);Console.ReadLine();}} }www.DoYoung.net(部分代碼來至杜洋工作室)
總結
以上是生活随笔為你收集整理的C#之windows桌面软件第十三课:C#中常用的类有哪些?构造函数怎么用?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#之windows桌面软件第十二课:电
- 下一篇: C#中如何将光标定位在某个控件中?