是什么铸造和转换之间的区别? [英] What is the difference between casting and conversion?
问题描述
埃里克利珀在这个问题已经离开了我彻底糊涂了。在C#铸造和转换之间的区别是什么?
Eric Lippert's comments in this question have left me thoroughly confused. What is the difference between casting and conversion in C#?
推荐答案
我相信埃里克想说的是:
I believe what Eric is trying to say is:
铸造是一个术语,描述语法(因此的句法的意思)。
Casting is a term describing syntax (hence the Syntactic meaning).
转换是一种术语,描述哪些行动实际上采取了幕后(因此的语义的意思)。
Conversion is a term describing what actions are actually taken behind the scenes (and thus the Semantic meaning).
一个铸前pression用于转换
明确一个前pression给定
类型。
A cast-expression is used to convert explicitly an expression to a given type.
和
形式(T),E的投-EX pression,
其中T是一个类型和E是
一元-EX pression,执行一个明确的
E的值转换(13.2节)
为T类型。
A cast-expression of the form (T)E, where T is a type and E is a unary-expression, performs an explicit conversion (§13.2) of the value of E to type T.
似乎回到了起来说,在语法转换运算符进行显式转换。
Seems to back that up by saying that a cast operator in the syntax performs an explicit conversion.
这篇关于是什么铸造和转换之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!