1、時間長度的計算 TimeSpan類。
例如:TimeSpan span = dateTime1 - dateTime2 方便啊
2、從類(Class)返回一個System.Type類型,用typeof關鍵字
3、從一個對象執行個體(Object)返回一個System.Type類型,用GetType方法
4、判斷是否處於設計狀態:DesignMode屬性
5、根據GUID建立對象執行個體
System.Guid pGuid = new Guid(guid);
System.Type ObjectCustorm = Type.GetTypeFromCLSID(pGuid);
Object obj = Activator.CreateInstance(ObjectCustorm);
6、GDI+不支援xor繪製模式的近似解決方案: ControlPaint.DrawReversibleFrame、ControlPaint.DrawReversibleLine方法
7、擷取Enum類型中的所有枚舉值: Enum.GetNames方法
將字串轉換成枚舉值 Enum.Parse方法
8、Label放在圖片上時,使Label透明 picLogo.Controls.Add(lblStatus); lblStatus.BackColor = Color.Transparent;
9、調用協助檔案
開啟協助檔案 Help.ShowHelp(this,@"c:/windows/help/mspaint.chm");
開啟協助檔案,並跳轉到指定的主題 Help.ShowHelp(this,@"c:/windows/help/mspaint.chm","paint_lines.htm");
開啟協助檔案,並轉到“索引”選項卡 Help.ShowHelpIndex(this,@"c:/windows/help/mspaint.chm","paint_lines.htm");
在螢幕上顯示一條浮動的協助資訊 Help.ShowPopup(this,"這裡是協助資訊",new Point(100,100));
10、通過AppDomain在應用程式之間傳遞資料
例如,兩個系統可能會共用登入資訊,登入一個系統後,再啟動另一個系統時,不需要重新登入。
先定義一個在應用程式之間傳遞的資料的類,該類必須從MarshalByRefObject繼承:
* from table1 minux truncate table table1; insert into table1 select * from table_new;