C#從零開始_自學C#、Visual Studio實境秀 34/ Inheritance char Excel ADO.Recordset Re...



{

Modifiers (C# Reference) http://bit.ly/2sCQK7m

static Declares a member that belongs to the type itself instead of to a specific object.

const Specifies that the value of the field or the local variable cannot be modified.

readonly Declares a field that can only be assigned values as part of the declaration or in a constructor in the same class.

所以方法簽章包含了:access modifier,return value,name,parameters. http://bit.ly/2vxSDEi

3:50 delegate

{

委派就如同代理人。也就是方法請委派代理執行。請委派代理執行方法。一個方法的仲介、白手套。

}

32:30 Inheritance (C# Programming Guide) http://bit.ly/2u5YRLP

{

Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes.

Structs do not support inheritance, but they can implement interfaces.

就像我們的功過格:Conceptually, a derived class is a specialization of the base class. For example, if you have a base class Animal, you might have one derived class that is named Mammal and another derived class that is named Reptile.

41:00 1:01:00 還有 static 也可以被繼承,如 object.ReferenceEquals() 就是。 the derived class implicitly gains all the members of the base class, except for its constructors and finalizers.

42:40 「從而」白話?文言? thereby 其實就是 by there (藉由那邊,不就是從那邊而怎樣嗎?) 九陽神功第三招 字形結構兼音義

「義」太重要了!!因為大家都是人,都有一個外在的客觀環境要去表述。

48:00 所以「implement」很重要 其實也不過就是我們具體寫出的程式嘛!不要把它想得好玄!實做,就是實實在在地去做出個可執行的程式碼來嘛!

1:21:00 所以 static 也類似 VBA 裡的用法,在程式執行階段可保留其值。

// Static field currentID stores the job ID of the last WorkItem that

    // has been created.

1:29:00 TimeSpan 時間間隔

4:48:00 4:50:50

5:03:30 parameters 、 arguments 混用不分!

5:41:00 if 、else if 的差別

5:43:30 CJk 擴充字集 已經到了F、G區了

5:45:05 字海、葉典網

6:09:00 Abstract and Virtual Methods Abstract是空洞無物的,而Virtual的是有物而可被取代的

6:15:30 「如果衍生類別本身就是抽象的,則會繼承抽象成員而不需要進行實作。」所以繼承的也可以是抽象的。

6:19:00 用抽象類別是防止類別被實例化的方法:You can declare a class as abstract if you want to prevent direct instantiation by using the new keyword.

6:21:15 implementation (method body).可見實做就是程式碼區塊的內容嘛。

6:22:40 An abstract class does not have to contain abstract members; however, if a class does contain an abstract member, the class itself must be declared as abstract.

抽象成員是抽象類別的充分而非必要條件!

6:29:00 An interface is a reference type that is somewhat similar to an abstract base class that consists of only abstract members.

interface 一定只有抽象成員。 6:30:00 class 實作 interface 不能選擇性辦案!要概括承受。

6:38:00 Interfaces are used to define specific capabilities for classes that do not necessarily have an "is a" relationship.

5:52:00 signature



}

1:55:00 1:57:40 Access 資料庫設計

{



2:19:10 2:15:00 用AdoDB 連線至 xls xlsx Excel 檔:

{Dim rst As New ADODB.Recordset



rst.ActiveConnection = "Provider = Microsoft.Jet.OLEDB.4.0;" & _

  " Data Source = E:\chap_B\custom.xls;" & _

  " Extended Properties=Excel 8.0;"

 

rst.Open "data_01" '要用 Excel Range

MsgBox rst.GetString

rst.Close

rst.Open "­q³æ"

MsgBox rst.GetString

}

2:27:00 2:29:55  Office Space:使用ADO 查詢Excel 試算表 - TechNet - Microsoft http://bit.ly/2uc7yGe

2:34:00 「無所不能」怎麼翻?文言文?白話文?

2:39:30  「為了保證您能順利從 Excel 試算表進行資料庫查詢,請務必按照下列方式安排試算表:把第一列當成標題列,從第二列開始輸入資料,不要跳過任何一列或欄。為了簡化編碼,標題請勿包含空格,……這樣可以避免很多麻煩 (這項原則適用任何類型的資料庫,不只是 Excel)。」

2:45:40 2:44:00

{



On Error Resume Next



Const adOpenStatic = 3

Const adLockOptimistic = 3

Const adCmdText = &H0001



Set objConnection = CreateObject("ADODB.Connection")

Set objRecordSet = CreateObject("ADODB.Recordset")



objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\Scripts\Test.xls;" & _

"Extended Properties=""Excel 8.0;HDR=Yes;"";"



objRecordset.Open "Select * FROM [Sheet1$]", _

objConnection, adOpenStatic, adLockOptimistic, adCmdText //關鍵是這一行的 "Select * FROM [fieldname$]"



Do Until objRecordset.EOF

Wscript.Echo objRecordset.Fields.Item("Name"), _

objRecordset.Fields.Item("Number")

objRecordset.MoveNext

Loop

「順便提醒,看到 Excel 8.0 時請不要手癢把版本改成您目前電腦上使用的 Excel 版本。這裡 Excel 8.0 指的並不是您目前使用的 Excel 版本,而是供 ADO 提供者用來存取 Excel 之用。將提供者保留為 Excel 8.0,保證不會出事情。

HDR=Yes 程式碼不過是用來指出範例中的試算表有標題列。如果試算表沒有標題列,要把 HDR 設定成 No。但希望讀者聽我們 Scripting Guy 的建議,要養成設定標題列的習慣,至於大家聽不聽得進去我們就不知道啦。」

工作表名稱用方括弧包住,且實際名稱 (Sheet1) 後面附加了一個 $。您撰寫自己的 ADO 指令碼時別忘了這兩個重點,才能存取試算表內的資料。

如今 要用「Microsoft.ACE.OLEDB.12.0」取代「Microsoft.Jet.OLEDB.4.0」才能取得完整的記錄錄集(recordset)



set myForm.recordset= Adodb.Redcordset

excelRange.CopyFromRecordset Adodb.Redcordset http://bit.ly/2tJPGPr

}



}



7:05:00 7:07:00 Char Struct http://bit.ly/2t46QXH

{Char objects, Unicode characters, and strings

7:09:20 characters 是 unicode 裡頭的東西,所以叫「Unicode characters 」

Most Unicode characters can be represented by a single Char object, but a character that is encoded as a base character, surrogate pair, and/or combining character sequence is represented by multiple Char objects.

所以一個 (unicode)charactera 可以用single Char object表示(represented by single Char)

也可以用 multiple Char objects來表示(represented by multiple Char objects either)

7:15:40 For this reason, a Char structure in a String object is not necessarily equivalent to a single Unicode character.

所以並不是一個 char 就代表一個 character ,因此 VBA裡 或C#裡的 len length 就不合用了,只能傳回 char count(數量,或長度)。

8:13:00 Multiple 16-bit code units are used to represent single Unicode characters in the following cases:

8:34:00 Len() 算出來的不等於 char object 物件的個數

8:35:40 亂碼的問號,不等於鍵盤打得出來的半形問號。

9:09:30 StreamWriter 寫入檔案

9:11:50 輸出目錄清單、檔案清單的寫法 The following example shows how to use a StreamWriter object to write a file that lists the directories on the C drive, and then uses a StreamReader object to read and display each directory name. http://bit.ly/2uHi8FZ

9:14:00 MarshalByRefObject

9:19:50 @".\chars2.txt"、"chars1.txt" 二者相同,都是寫在預設的 debug 輸出目錄下

9:29:40 Char.ConvertFromUtf32()  Convert.ToUInt16()

9:41:40 System.Globalization.UnicodeCategory,

  public static void Main()

  {

 // Define a string with a variety of character categories.

 String s = "The car drove down the narrow, secluded road.";

 // Determine the category of each character.

 foreach (var ch in s)

Console.WriteLine("'{0}': {1}", ch, Char.GetUnicodeCategory(ch));



  }//所以一個字串 String 可以當成字元(character)的集合或陣列來處理。String 是由 chars 排列組合成的





}



 7:25:00 吳老師 吳清輝

 http://bit.ly/2uH95oB 7:43:00 [Excel VBA] 大量字串取代的做法「因為程式裡用 Cells.Replace 是沒有指定工作表,就是針對 Active 的工作表,而沒有指定 Cell 的 Row, Column,所以是針對整張工作表所有的儲存格做取代。」 http://bit.ly/2uf9kF1



}


留言

熱門文章