C#從零開始_自學C#、Visual Studio實境秀 24/ Generics class struct 轉型、陣列排序…… {



35:00 Generics (C# Programming Guide) http://bit.ly/2u5llzr

44:45 角括弧或尖括弧的用法

1:22:00 所以接口(介面 interface)就是一種抽象的基底類型(class)。

The following are merged from all the partial-type definitions: //http://bit.ly/2u5Jh5M

XML comments

interfaces

generic-type parameter attributes

class attributes

members

For example, consider the following declarations:

C#



Copy

partial class Earth : Planet, IRotate { }

partial class Earth : IRevolve { }

They are equivalent to the following declarations:

C#



Copy

class Earth : Planet, IRotate, IRevolve { }



1:27:00

Object and Collection Initializers. 像功過格裡就可以用 Collection



1:37:40 Auto-Implemented Properties 就是最簡潔的 get set 存取器其實就是「屬性」的寫法!)

即在上一集(23)中「3:15:00 原來屬性(get set accessors 存取子或存取器 寫成  public int Number { get; set; } 即可」

http://bit.ly/2sCYvuC

auto-implemented properties make property-declaration more concise when no additional logic is required in the property accessors.

http://bit.ly/2sCVWJd Auto-Implemented Properties (C# Programming Guide)

1:46:00 Anonymous Types 匿名引用(class)就是不指名(不指明)其類別(class)就去引用或宣告一個執行個體

http://bit.ly/2tVD6AJ



1:59:00 How to: Implement a Lightweight Class with Auto-Implemented Properties (C# Programming Guide)



2:28:40 不是每個 namespace 都要用一次 using ,巢狀 namespace 在其最外層 namespace 或 cs file 最頂端 using 即可

2:49:00 interface 名稱前面會有一個大寫「I」識別,如: I​Enumerable<​T> Interface // http://bit.ly/2sCAZ12



3:28:00 物件導向的三大原則:封裝(Encapsulation)、繼承(Inheritance)、多型(Polymorphism)



3:38:40 statement 程式碼執行指令行; 3:53:15



4:10:00 Lambda Expressions (C# Programming Guide)

Extension Methods (C# Programming Guide)

4:23:10 陣列排序 http://bit.ly/2tZOZ8L 4:36:00



5:10:40 http://bit.ly/2uY77gl  Implicitly Typed Local Variables (C# Programming Guide) http://bit.ly/2uEN6MA var (C# 參考)



5:28:00 Collection initializers http://bit.ly/2sCYvuC

5:34:00 object initializers

5:36:00 List<T> http://bit.ly/2uYxMd4

http://bit.ly/2tvNXjO http://referencesource.microsoft.com/

Reference Source 5:50:30 就是從這裡來的



6:30:00 改良「部件篩選器.exe」 static readonly get 實作;也知道,為什麼不用 method return 而用 property get ;因為 property 比較直觀, method 引用時還得加 ();



6:52:00 可以讀文字檔進來:

using (var file = new StreamReader("C:\\myfile.txt")) {...}

http://bit.ly/2uY77gl



7:31:15 可以讓Word成作用中視窗:

                    dn.ActiveWindow.Visible = true;

                    dn.ActiveWindow.Activate();//要先激活才有效,若先放大再激活就不會呈現在畫面上

                    //dn.ActiveWindow.WindowState = WdWindowState.wdWindowStateMinimize;

                    dn.ActiveWindow.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMaximize;

                    dn.Application.Activate();



7:37:40 ExternalException http://bit.ly/2tWCWJr

ExternalException.ErrorCode 屬性 Gets the HRESULT of the error.

http://bit.ly/2uF0NLa



 catch (System.Exception e )

 {

  ExternalException eHandle = (ExternalException)e;

  if (eHandle.ErrorCode == -2146233080)

  { add_d = d.Application.Documents.Add(); goto bj; }//還有一個錯誤即若Word裡有訊息方塊,就會。

 

http://tinyurl.com/y7u4qw8k 7:42:40 ErrorCode "-2147417851" HResult



 或者直接寫成:

 catch (ExternalException eHandle )

 {

  if (eHandle.ErrorCode == -2147417851)                      

  { add_d = d.Application.Documents.Add(); goto bj; }

因為 ExternalException 是 Exception 的 derived class 可以 implicit type conversions。


留言

熱門文章