14.4.2.3 Better conversion

王朝other·作者佚名  2006-02-28
窄屏简体版  字體: |||超大  

Given an implicit conversion C1 that converts from a type S to a type T1,

and an implicit conversion C2 that

converts from a type S to a type T2, the better conversion of the two

conversions is determined as follows:

?If T1 and T2 are the same type, neither conversion is better.

?If S is T1, C1 is the better conversion.

?If S is T2, C2 is the better conversion.

?If an implicit conversion from T1 to T2 exists, and no implicit

conversion from T2 to T1 exists, C1 is the

better conversion.

?If an implicit conversion from T2 to T1 exists, and no implicit

conversion from T1 to T2 exists, C2 is the

better conversion.

?If T1 is sbyte and T2 is byte, ushort, uint, or ulong, C1 is the better

conversion.

?If T2 is sbyte and T1 is byte, ushort, uint, or ulong, C2 is the better

conversion.

?If T1 is short and T2 is ushort, uint, or ulong, C1 is the better

conversion.

C# LANGUAGE SPECIFICATION

136

?If T2 is short and T1 is ushort, uint, or ulong, C2 is the better

conversion.

?If T1 is int and T2 is uint, or ulong, C1 is the better conversion.

?If T2 is int and T1 is uint, or ulong, C2 is the better conversion.

?If T1 is long and T2 is ulong, C1 is the better conversion.

?If T2 is long and T1 is ulong, C2 is the better conversion.

?Otherwise, neither conversion is better.

If an implicit conversion C1 is defined by these rules to be a better

conversion than an implicit conversion C2,

then it is also the case that C2 is a worse conversion than C1.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航