日期:2014-05-17 浏览次数:20875 次
string value = "10";
int iValue = Convert.ToInt16(value);
string value2 = "10";
object obj = value2;
int objValue = (int)obj;
IL_0000: nop
IL_0001: ldstr "10"
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: call int16 [mscorlib]System.Convert::ToInt16(string)
IL_000d: stloc.1
IL_000e: ldstr "10"
IL_0013: stloc.2
IL_0014: ldloc.2
IL_0015: stloc.3
IL_0016: ldloc.3
IL_0017: unbox.any [mscorlib]System.Int32
IL_001c: stloc.s V_4
IL_001e: ret
public static short ToInt16(string value)
{
if (value == null)
{
return 0;
}
return short.Parse(value, CultureInfo.CurrentCulture);
}
public static short Parse(string s, IFormatProvider provider)