C# 常用命名空間和函數


別人的,留着備用

1. using System.Collections; 
有ArrayList;Hashtable;Stack;Queue;DictionaryEntry;等集合 

2. using System.Reflection; 
獲取Assembly 的屬性值 

3. using System.Data; 
訪問和操作數據庫等類 

4. using System.Drawing; 
圖像,畫筆,和gdi 

5. using System.IO; 
對文件、文件夾的操作 

6. using System.Media; 
播放wav和系統wav文件 

7. using System.Net; 
操作網絡 

8. using System.Runtime; 
運行時的各種信息 

9. using System.Security; 
用於安全和加密 

10.using System.Text; 
各種編碼方式和正則表達式 

11.using System.Threading; 
多線程 

12.using System.Web; 
asp.net的web編程 

13.using System.Windows.Forms; 
各種控件 

14.using System.Xml; 
操作xml文件 

常用類 

15. Microsoft.Win32.Registry 
  操作注冊表 

16. System.Runtime.InteropServices.Marshal 
  操作內存 

17. System.Enum; 
  操作枚舉 

18. System.DateTime; 
  操作時間 

19. System.Math; 
  操作數字類 

20. System.Runtime.Serialization 
  用於序列化和反序列化 

21. System.Windows.Forms.Clipboard; 
  操作剪貼板 

22. DateTime.IsLeapYear("1990"); 
   判斷是否為閏年 

23. System.Text.RegularExpressions.Regex.IsMatch("字符串","正則表達式"); 
   判斷正則,返回bool型 
       
24. Console.CapsLock; 
   獲取caps_lock鍵,是否按下 

25. System.Environment; 
   System.Windows.Forms.SystemInformation;   
    獲取系統信息 
   
   
26. System.Array; 
   操作數組,排序,倒序等 

27. System.Windows.Forms.Screen s = Screen.PrimaryScreen; 
   獲取顯示器信息 

28. System.Guid.NewGuid(); 
   獲取新的guid 

29. System.Random r = new Random(); 
   r.Next(); 
   產生隨機數 

30. System.Drawing.Point p = new Point(100,200); 
   System.Drawing.Size s = new Size(500,600); 
   位置和大小 

31. System.Threading.Thread.Sleep(3000); 
   延遲三秒 

32. System.Drawing.Point p = MousePosition; 
   獲取當前鼠標坐標


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM