Posted inC# // .net [C#]紮穩馬步//.net 基本語法、變數與資料型別 Posted by lulu 2014-04-27No Comments 1.Only Intel CPU2.Microsoft. 的namespace不是base class library3.namespace 只是用來分類的4.managed/unmanaged:差異於資源是否會自動配置5.win8有windows runtime ,但是仍是win32 API6.XAML未仍淘汰(使用Blend設計)7.win8=> a.C# + XAML b.Javascript + HTML5 (win app store上架)8.code coverage> 50%以上比較好9.Unit Test => Method ,input 及output驗證10.Solution的功用: a.Debug(跨專案debug) b.Refactor重構,例如:Rename11.Control=>toolbox裡的control,大部份是具備UI的物件,所以不需要使用New,State使用Property來設定。12.event driven event handler 使用dbclick註冊event時,會做二個動作 //1.產生副程式 //2.在.Designer加入delegate // this.button1.Click += new System.EventHandler(this.button1_Click); ===================變數與資料型別 ================================= 重點整理: .Value Type / Reference Type .無論Value Type 或是 Referenct Type。 所有的資料型別皆是繼承System.Object,所以可以使用System.Object的方式來操作它 =>ex: 10.ToString() , 10.GetType() .value type => ex: int , float , double,char,bool … =>長度(size)是固定的 .value type => 會自動轉為System.____ 是 common type system(CTS),用於跨語言溝通(VB <=> C#) .struct:為輕量的object, 不可以繼承。 .struct 中的 constructor ,不可以宣告”預設”的建構函式。 因為它不是reference,所以不需要new。 所以宣告預設的建構函式並沒有功用。 在struct中用建構函式,是為了要快速宣告初始值而已。 並不會建立Object.而是會跳入執行該method而已。 .int i = new int(); =>是合法的宣告初始值。i在此會初始為 0。 DateTime d = new DateTime(); //default constructor .enum 列舉型別資料=>繼承ValueType a.使用.GetHashCode() 可取得整數值。 b.使用explicit , (int) 也可取得整數值。 .anonymous type 匿名型別 => var => .net 3.0 以上 => 一定要有初始值。編譯器才能推測資料型態。 => 只能用在區域變數 分享此文: 分享到 Facebook(在新視窗中開啟) Facebook 分享到 X(在新視窗中開啟) X 請按讚:喜歡 正在載入... lulu View All Posts Post navigation Previous Post [iOS]0.準備作業:MAC OSX & Windows 的鍵盤及操作對應Next Post[.net] 線上寫程式,是有沒有這麼酷!