Widening (Visual Basic)Widening (Visual Basic)

表示轉換運算子 (CType) 將類別或結構轉換成的型別,可以保留原始的類別或結構的所有可能的值。Indicates that a conversion operator (CType) converts a class or structure to a type that can hold all possible values of the original class or structure.

轉換擴展關鍵字Converting with the Widening Keyword

轉換程序必須指定Public Shared除了WideningThe conversion procedure must specify Public Shared in addition to Widening.

擴展轉換時,一律在執行階段成功,而且永遠不會造成資料遺失。Widening conversions always succeed at run time and never incur data loss. 範例包括SingleDoubleCharString,和其基底類型衍生型別。Examples are Single to Double, Char to String, and a derived type to its base type. 因為衍生的型別包含基底類型的所有成員,因此是基底類型的執行個體,則會擴展這個最後一個轉換。This last conversion is widening because the derived type contains all the members of the base type and thus is an instance of the base type.

使用的程式碼不需要使用CType的擴展轉換,即使Option StrictOnThe consuming code does not have to use CType for widening conversions, even if Option Strict is On.

Widening關鍵字可以用在此內容中:The Widening keyword can be used in this context:

Operator 陳述式Operator Statement

定義擴展和縮小轉換運算子,例如看到How to:定義轉換運算子For example definitions of widening and narrowing conversion operators, see How to: Define a Conversion Operator.

另請參閱See also