对于类型转换运算符,操作数或返回类型必须是类或结构的数据类型。
For a type conversion operator, either the operand or the return type must be of the data type of the class or structure.
为可空类型提供类库支持,包括转换运算符和算术运算符。
Library Support for nullable types, including conversion operators and arithmetic operators.
转换的定义方法类似于运算符,并根据它们所转换到的类型命名。
Conversions are defined like operators and are named for the type to which they convert.
通过使用适当的运算符,可以轻松地将枚举转换为基础类型,如以下代码中所示。
You can easily convert enumerations to the underlying type by using the appropriate operator, as shown in the following code.
一个转换运算符的定义,返回您的类或结构的类型。
A definition of a conversion operator that returns the type of your class or structure.
源类型提供转换运算符。
对于向上转换运算符,如果编译器无法根据上下文推断出特定的目标类型,则将报告错误。
As for the upcast operator, if the compiler cannot infer a specific target type from the context, it reports an error.
在使用向上转换运算符时,编译器会尝试根据上下文来推断出要转换为的类型。
When you use the upcast operator, the compiler attempts to infer the type you are converting to from the context.
不过,可为类型定义隐式转换运算符,这样就可以对这些类型使用赋值运算符。
However, you can define implicit conversion operators for a type, which enable you to use the assignment operator with those types.
转换运算符将源类型转换为目标类型。
The conversion operator converts from a source type to a target type.
转换运算符将源类型转换为目标类型。
The conversion operator converts from a source type to a target type.
应用推荐