public override string ToString() |
{ |
return InternalFormat((RuntimeType) base.GetType(), this.GetValue()); |
} |
|
private static string InternalFormat(RuntimeType eT, object value) |
{ |
if (eT.IsDefined(typeof(FlagsAttribute), false)) |
{ |
return InternalFlagsFormat(eT, value); |
} |
string name = GetName(eT, value); |
if (name == null) |
{ |
return value.ToString(); |
} |
return name; |
} |
ToString()大概了解了。那么
int i=1;
string aa=i+"";
string aa=i.ToString();
这两者的内核区别事那些呢?
string aa=i+""; 先对i执行ToString,然后进行字符串对象的拼接,生成一个新的字符串对象
i.ToString(); 直接执行ToString函数