你是在怀疑
 decimal a3=(Char)(a1+a2);
这一句,能够正常运行的原因吗?当然是隐式类型转换的原因喽。

解决方案 »

  1.   

    隐式类型转换?
     为啥不int a3=(Char)(a1+a2);  就不行~ 而
    偏偏
    decimal a3=(Char)(a1+a2); 
    可行?
      

  2.   

    隐式数值转换包括以下几种:●从sbyte类型到short,int,long,float,double,或decimal类型。●从byte类型到short,ushort,int,uint,long,ulong,float,double,或decimal类型。●从short类型到int,long,float,double,或decimal类型。●从ushort类型到int,uint,long,ulong,float,double,或decimal类型。●从int类型到long,float,double,或decimal类型。●从uint类型到long,ulong,float,double,或decimal类型。●从long类型到float,double,或decimal类型。●从ulong类型到float,double,或decimal类型。●从char类型到ushort,int,uint,long,ulong,float,double,或decimal类型。●从float类型到double类型。显式数值转换是指当不存在相应的隐式转换时,从一种数字类型到另一种数字类型的转换。包括:●从sbyte到byte,ushort,uint,ulong,或char。●从byte到sbyte或char。●从short到sbyte,byte,ushort,uint,ulong,或char。●从ushort到sbyte,byte,short,或char。●从int到sbyte,byte,short,ushort,uint,ulong,或char。●从uint到sbyte,byte,short,ushort,int,或char。●从long到sbyte,byte,short,ushort,int,uint,ulong,或char。●从ulong到sbyte,byte,short,ushort,int,uint,long,或char。●从char到sbyte,byte,或short。●从float到sbyte,byte,short,ushort,int,uint,long,ulong,char,或decimal。●从double到sbyte,byte,short,ushort,int,uint,long,ulong,char,float,或decimal。●从decimal到sbyte,byte,short,ushort,int,uint,long,ulong,char,float,或double。