飲水思源:金老師的自學網站多線程
基本類型的變量值能夠自動裝箱到一個object對象中,app
反過來,object對象也能夠強制轉化獲得基本類型值。函數
class Program { static void Main(string[] args) { int i = 3; object obj = i; int j = (int) obj; } }
裝箱和拆箱會帶來較大性能損失,應當避免。性能
什麼是「只讀」對象:一旦建立,內容不可更改網站
爲何要設計「只讀」對象:多線程環境能夠提高程序性能(訪問時無需互斥)spa
如何設計「只讀」類:類比高階函數,當外界指望修改對象的字段值時,不改變原對象內容,而是建立一個新對象以知足需求。線程
static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }
new誰,誰就是啓動窗體。設計
private void button1_Click(object sender, EventArgs e) { var form2 = new Form2(); form2.ShowDialog(); }
如圖所示:code
ShowDialog後,不關閉從窗體,沒法激活主窗體。orm
而Show則能夠:
固然,並非說Show以後從窗體徹底脫離主窗體存在,主窗體結束,從窗體會一同跟着結束。