/// <summary> /// Class designed to give information /// about the current system /// </summary> public static class Environment { #region Public Static Properties /// <summary> /// Name of the
/// <summary> /// Process extensions /// </summary> public static class ProcessExtensions { #region Functions #region KillProcessAsync /// <summary> /// Kills a process ///
在C#3.X中引進了var這個新關鍵字,在聲明局部變數時可用於替代原先的類型名,即當一個變數宣告身份識別為var類型並且該範圍域中沒有var名稱類型存在,那麼這個聲明就稱為隱含類型局部變數。先來看個完整的DEMO吧:CodeCode highlighting produced by Actipro CodeHighlighter
CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System;using System.Collections.Generic;using System.Text;using System.Threading;namespace ConsoleApplication1{class Program {static void
C#中的方法需要一個明確的方法簽名,簽名包括以下內容:傳回型別、方法名稱和參數列表。有時也包括訪問限制符。 簽名中的參數列表中的參數數目包括固定和不固定兩種類型,數目固定的情況是我們經常見到的,不固定的則是很少見的。 例如,當我們需要實現一個整數加法的時候,可能首先想到的是下面的形式:CodeCode highlighting produced by Actipro CodeHighlighter
.NET中許多類都提供了兩種不同的途徑可以處理來自系統的事件,一方面我們可以使用事件處理器,另一方面我們可以重寫基類的虛方法。這兩種方式有各自不同的用途,在衍生類別中,我們應該使用重寫虛方法的方式,來處理系統事件。 關於上述兩種方式,我們看以下的代碼。代碼Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 public class
事件為類型定義了外發介面,C#的事件是建立在委託的基礎上的,委託為事件處理器提供了型別安全的函數簽名。 委託要比事件的使用範圍廣泛,我們可以把事件看做是一種經過了封裝的委託,專門用於事件驅動模型。你可以在客戶代碼中直接調用委託來激發委託指向的函數,而事件不可以,你只能在服務端呼叫事件,在用戶端呼叫事件是會引發編譯錯誤的。我們來看下面的程式。代碼Code highlighting produced by Actipro CodeHighlighter (freeware)http:/