C#從零開始_自學C#、Visual Studio實境秀 36/ Types Extension methods Static



{

12:20 Built-In Types Table (C# Reference) http://bit.ly/2tLV2d4

12:40 The following table shows the keywords for built-in C# types, which are aliases of predefined types in the System namespace.

14:45 The C# type keywords and their aliases are interchangeable.

For example, you can declare an integer variable by using either of the following declarations:

int x = 123;

System.Int32 x = 123;

To display the actual type for any C# type, use the system method GetType()

You can also use the typeof operator.

typeof (C# Reference) http://bit.ly/2tLVuYO

To obtain the run-time type of an expression, you can use the .NET Framework method GetType,

23:00 格式化 Formatting Numeric Results Table (C# Reference)

26:30 dynamic (C# Reference) http://bit.ly/2vqpdIS

The dynamic type simplifies access to COM APIs such as the Office Automation APIs, and also to dynamic APIs such as IronPython libraries, and to the HTML Document Object Model (DOM).

32:00 dynamic 類似彈性類別 或自動偵測類別



Types (C# Programming Guide) http://bit.ly/2t4lwWY

{

C# is a strongly-typed language.強型別(強式類型)

47:50 type safe 型別安全

49:30 in C#, bool is not convertible to int.

50:15 metadata 中繼資料

51:05 common language runtime (CLR)

52:20 Declaration only:  Declaration with initializers

55:20 LinQ 母清單(source)傳回子清單(query):

var query = from item in source

where item <= limit

select item;

57:25 method signature 方法簽章

1:04:00 小小輸入法詞庫

1:08:00 argument parameter

1:11:20 After a variable is declared, it cannot be re-declared with a new type,

implicitly type conversion:

A type conversion that does not cause data loss is performed automatically by the compiler.

1:13:00 A conversion that might cause data loss requires a cast in the source code.

1:13:30 Casting and Type Conversions.

1:15:00 法外開恩

1:16:00 You use the struct, class, interface, and enum constructs to create your own custom types.

interface 果然與 class 是同一級的、同一類的

The .NET Framework class library itself is a collection of custom types provided by Microsoft that you can use in your own applications.

1:23:00 用程式控制PDF檔:adobe acrobat type library vba http://bit.ly/2tmbnpw 加入參考也有

1:29:40 Common Type System (CTS) http://bit.ly/2uFYrPb

1:35:00 Each type in the CTS is defined as either a value type or a reference type.

1:36:00 Types that you define by using the struct keyword are value types; all the built-in numeric types are structs. Types that you define by using the class keyword are reference types.

1:42:50 There are two categories of value types: struct and enum.

1:45:45 because a struct can only inherit from System.ValueType.However, a struct can implement one or more interfaces.

You can cast a struct type to an interface type; this causes a boxing operation to wrap the struct inside a reference type object on the managed heap.

1:46:45 Boxing operations occur when you pass a value type to a method that takes a System.Object as an input parameter. For more information, see Boxing and Unboxing.

You use the struct keyword to create your own custom value types. Typically, a struct is used as a container for a small set of related variables

1:50:40 所以 enum 只能用在整數常值上 The other category of value types is enum. An enum defines a set of named integral constants. 列舉會定義一組具名的整數常數。

the name is much more meaningful for humans reading the source code,

All the rules that apply to structs also apply to enums.

1:56:50 A type that is defined as a class, delegate, array, or interface is a reference type.

2:04:00 when you declare a variable of a reference type, the variable contains the value null until you explicitly create an instance of the object by using the new operator, or assign it an object that has been created elsewhere , as shown in the following example:

2:08:20 所以一個 interface 要初始化一定要用一個類別的執行個體來實作: An interface must be initialized together with a class object that implements it.

If MyClass implements IMyInterface, you create an instance of IMyInterface as shown in the following example:

IMyInterface iface = new MyClass();

2:10:10 When the object is created, the memory is allocated on the managed heap, and the variable holds only a reference to the location of the object.

holds only a reference to the location of 這就是提貨券嘛!

2:13:50 Automatic Memory Management. 記憶體管理 http://bit.ly/2tMFNRg

2:15:40 Reference types fully support inheritance.

2:16:10 For more information about how to create your own classes, see Classes and Structs.

2:17:10 Types of Literal Values 可以翻成「常值型別」嗎?

For more information about which types can be specified with letter suffixes, see the reference pages for individual types in Value Types.

2:24:30 Generic Types:A type can be declared with one or more type parameters that serve as a placeholder for the actual type (the concrete type) that client code will provide when it creates an instance of the type. Such types are called generic types.

Generic Types 就類似空頭支票,程式在使用它時,就要簽票、背書。就是一開始,不指明,不具名……

也是所謂虛席以待,泛、泛愛眾的泛

2:31:00 System.Collections.Generic.List<T> has one type parameter that by convention is given the name T. When you create an instance of the type, you specify the type of the objects that the list will contain,

2:37:20 可見 var 只能用在 區域變數 you can implicitly type a local variable (but not class members) by using the var keyword.

2:39:20 先抓動詞!九陽神功第七招

2:41:00 就是不想概括承受就用匿名型別:In some cases, it is inconvenient to create a named type for simple sets of related values that you do not intend to store or pass outside method boundaries. You can create anonymous types for this purpose. For more information, see Anonymous Types.

2:44:30 Nullable Types



}

Access Modifiers (C# Programming Guide) http://bit.ly/2tgbF1S

{

3:03:00 interfaces default to internal access.

Interface members are always public because the purpose of an interface is to enable other types to access a class or struct. No access modifiers can be applied to interface members.

3:06:20 Enumeration members are always public, and no access modifiers can be applied.

3:06:30 Delegates behave like classes and structs. By default, they have internal access when declared directly within a namespace, and private access when nested.

這不是說 delegates 和 classes structs 是一樣的層級,而是說他們在 accessibility 的 default 上是和 classes structs一樣的!

}

3:33:00 Extension Methods (C# Programming Guide) http://bit.ly/2tZOZ8L 擴充方法

{

Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type.

OrderBy 3:35:30

3:41:30 Extension methods are defined as static methods but are called by using instance method syntax.

this

3:50:30 漢字資訊處理 測試計算漢字字串長度,需要有分隔條件才能。

}

Static Classes and Static Class Members (C# Programming Guide)

{

4:05:30 靜態的不可存取非靜態的:Static methods and properties cannot access non-static fields and events in their containing type, and they cannot access an instance variable of any object unless it is explicitly passed in a method parameter.

4:08:00 Static methods can be overloaded but not overridden, because they belong to the class, and not to any instance of the class.

4:09:00 Although a field cannot be declared as static const, a const field is essentially static in its behavior. It belongs to the type, not to instances of the type.

4:10:00 區域變數不能宣告為 static C# does not support static local variables



}



}


留言

熱門文章