條框7:將實值型別儘可能實現為具有常量性和原子性的類型常量性——自建立後保持不變,無法修改;安全執行緒。我們需要注意常量類型中的可變參考型別欄位,在實現構造器的時候,需要對其中的可變類型進行防禦性的複製。CodeCode highlighting produced by Actipro CodeHighlighter
public static void AddMIMEType(){ DirectoryEntry rootEntry = GetDirectoryEntry("IIS://localhost/w3svc/1/root"); foreach(PropertyValueCollection pc in rootEntry.Properties) { Console.WriteLine(pc.PropertyName+":"+pc.Value); }
在C#中,聲明 兩個int類型的變數 i 和 j ,有兩種聲明方式:static void Main(string[] args) { int i; int j;}static void Main(string[] args) { int i, j;} 今天在看《C#進階編程》時,看到了他們的區別,記錄下來。 PS:i和j在同一範圍中。 int類型屬於實值型別,而實值型別是儲存在棧中的,棧的資料存放區屬於後進先出(last-in, first-out,
.Net定時快顯視窗(c#) using System;using System.Collections;using System.ComponentModel;using System.Web;using System.Web.SessionState;using System.Threading;using System.Timers;namespace PopUp { public class Global : System.Web.HttpApplication { private
Regex(regular expressions)是一套文法匹配規則,各種語言,如perl, .Net和Java都有其對應的共用的Regex類庫。在.Net中,這個類庫叫做regex。簡單的說,regex是從字元窗中尋找匹配字串的應用類。通過regex,編程人員能夠非常方便的從一段資料中提取自己所需要的資料資訊。舉一個簡單的例子,讓大家對regex有個大概的瞭解:regex regex = new regex(@"d+"); match m = regex.match("fox
c#已提供了串口通訊組件SerialPort,但是C#並沒有提供直接的並口通訊組件,只好通過調用API來與並口通訊 代碼Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 using System; 2 using System.Runtime.InteropServices; 3 namespace LptPrint_test 4 { 5