C#從零開始_自學C#、Visual Studio實境秀 23/ Word操作再熟悉: GetActiveObject,static,class...



23/ Word操作再熟悉: GetActiveObject,static,classes,structs...{ https://youtu.be/P1zrgGXTTSg
完善「部件篩選器.exe」
56:40 要解決Word Exception;
Marshal.BindToMoniker Marshal.GetActiveObject

1:30:00 static 、 class 、member 、Structs 、 Classes, Objects, and Structs. //http://bit.ly/2sYuLI8
2:32:40 static 就好像族類(Class)的「禁臠」一樣。 4:07:30 沒有必要給依據它(class)建構的個來來使用的話,就在Class自身宣告為 static 即可。
4:54:20 Other methods and properties might be only for use in the class or struct itself. It is important to limit the accessibility of your code so that only the intended client code can reach it.  http://bit.ly/2sYuLI8
4:56:39 class > type > object
4:58:10 the access modifiers 修飾詞
You specify how accessible your types and their members are to client code by using the access modifiers public, protected, internal, protected internal, and private.


4:09:00 Methods and variables that are not intended to be used from outside of the class or assembly can be hidden to limit the potential for coding errors or malicious exploits. http://bit.ly/2sYuLI8
4:10:40 常數(常量 constants )、變數(變量 fields )的差別就在編譯時常量會被改寫成常量值(則常量或常數名稱就會被覆寫(overridden) ,而變量不會。

2:32:17 Structs 和 Classes 就在傳值(value type)與傳址(reference type)://http://tinyurl.com/y9oj99g9
A class is a reference type. When an object of the class is created, the variable to which the object is assigned holds only a reference to that memory. When the object reference is assigned to a new variable, the new variable refers to the original object. Changes made through one variable are reflected in the other variable because they both refer to the same data. +
A struct is a value type. When a struct is created, the variable to which the struct is assigned holds the struct's actual data. When the struct is assigned to a new variable, it is copied. The new variable and the original variable therefore contain two separate copies of the same data. Changes made to one copy do not affect the other copy.
4:01:10 Unlike structs, classes support inheritance, a fundamental characteristic of object-oriented programming. For more information, see Inheritance.
5:28:40 可見 protected 和 inheritance 的關係。//http://bit.ly/2tgbF1S :
Struct members cannot be declared as protected because structs do not support inheritance.

5:40:00 終於搞懂什麼叫 casting 什麼叫 type Conversions了 Class 和 type 有什麼不同。http://tinyurl.com/yabblj3k
type 應該是翻成「種」,class 生成「類」 比較好懂
casting :
Image = (Image)data.GetData(DataFormats.Bitmap)
PictureBox picBox = sender as PictureBox;
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
Type Conversions:
public static double FahrenheitToCelsius(string temperatureFahrenheit)
        {
            // Convert argument to double for calculations.
            double fahrenheit = Double.Parse(temperatureFahrenheit);}

也就是 class 對 class 的就是 casting ;而其 class 的成員的 type 就是 type conversions.
type 是屬於 class的 members的 ;而 class 就是 class 本身囉 5:52:20
我是由以下這段讀懂的:
For example, you cannot have a public method M that returns a class C unless C is also public. Likewise, you cannot have a protected property of type A if A is declared as private. //http://bit.ly/2tgbF1S
property of type,property 不就是在class 宣告、設定的嗎?所以我們不能稱為 property of class 卻可以叫做 property of type,而type就是class,卻不是class本身。
5:53:00 也就是說,一個member (property,event,method,const,...)屬於哪一種 class,它就是那一種 type;(它是從哪一種 class 造出來的,它就有哪一種 type)
可是這個 class 好像不能自訂的。須系統定的,如 String > string ;如:
// public class:
public class Tricycle
{
    // protected method:
    protected void Pedal() { }

    // private field:
    private int wheels = 3;

    // protected internal property:
    protected internal int Wheels  // int 是 type ;可是這個 property 卻是在 Tricycle這個 Class 下 宣告 產生 製造 的
    {
        get { return wheels; }
    }
}

6:13:00 protected internal 的 禁錮範圍

6:17:00 Interfaces  http://bit.ly/2tgbF1S
 the purpose of an interface is to enable other types to access a class or struct.
6:21:00 enum
 Enumeration members are always public, and no access modifiers can be applied.



3:15:00 原來屬性(get set accessors 存取子或存取器 寫成  public int Number { get; set; } 即可

3:28:40 原來 namespace 裡還可以有 namespace, class 裡頭也可以有 class;而 using 是要分別在每個 namespace 裡使用(宣告)才有效;
5:12:30
真的有巢狀的 classes ://http://bit.ly/2tgbF1S
Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. Internal is the default if no access modifier is specified.
Nested Types (< 這個 Types 翻成「式」,更合適易懂;即巢狀式的 classes or structs)//http://bit.ly/2sYuLI8
A class or struct can be nested within another class or struct. For more information, see Nested Types.
5:13:25 難怪我們預設裡都可以在別的 class 呼叫另一個 clase 就是因為他的預設是 internal
5:16:40 而他們的成員,則預設都不可以直接用 dot notation 呼叫:The access level for class members and struct members, including nested classes and structs, is private by default.

3:34:00 Main() 系統給的預設會是 static void Main(string[] args) ,而我們自己寫可省略引數。
3:39:40 程式進入的 point 可在 方案總管裡點二下 Properties 打開的頁籤中『應用程式』裡頭的『啟始物件』設定

4:20:00 In C#, there are no global variables or methods as there are in some other languages.  http://bit.ly/2sYuLI8
public 難道不是 global 嗎?

4:22:20 http://bit.ly/2sYuLI8
 The following list includes all the various kinds of members that may be declared in a class or struct.
Fields
Constants
Properties
Methods
Constructors
Events
Finalizers
Indexers
Operators
Nested Types

4:53:10 Accessibility(協助工具選項--翻錯了) http://bit.ly/2uXmRA5

6:36:00 classes and structs
Inheritance 不能繼承 建構子 和 解構子 http://bit.ly/2sYuLI8
A class that derives from another class (the base class) automatically contains all the public, protected, and internal members of the base class except its constructors and finalizers.
6:48:00 class 像 property 後接 大括弧 結尾,沒有 小括號; namespace 也一樣
http://bit.ly/2uElxmj
6:52:00 sealed 和 static 的差別: sealed 是用在類與類之間繼承的關係; static 是用在 類( class )與個體( object )之間。都是「禁臠」的意思。
700:00 sealed (C# Reference) http://bit.ly/2uElxmj

7:30:00 Interfaces Summary http://bit.ly/2tVznTX
7:33:30 多重繼承(c# 只能單一繼承,卻可以多重實做接口(介面),也類似多重繼承了嘛。也就是可以做些interface讓單一class來(繼承)實做它。因為interface也是一種特殊的Clase:An interface is like an abstract base class. 其實接口(interface)就是一種抽象的基底類型。
A class or struct can implement multiple interfaces. A class can inherit a base class and also implement one or more interfaces.
這就是多重繼承在c#實現的轉寰方式。 http://bit.ly/2tVznTX
structs,interfaces....其實都是class,只是不同type而已!(不同type的class!)

7:50:00 the IEquatable interface



}

留言

熱門文章