I was wondering :
writing this code :
DataRow[] g = new DataRow[1] ;
var t=new StringBuilder().AppendFormat("{0}", g[0]["aaa"].ToString());
Resharper shows it like : ( notice the gray )


3 questions please
1) removing ToString() , how will the object will output its display string without calling the removed ToString() ?
2) does it suggest to remove it because he already calls it internally ? or because of another reason ?
3) not removing ToString() , will it call it twice ?
Yes, it is redundant because
AppendFormat(likeString.Format) internally already converts it to a string andString.ToStringis always redundant.Actually it uses the
ICustomFormatter.Formatmethod on every provided parameter.It’s also redundant in terms of useless. So even if no work needs to be done multiple times(
AppendFormatwill not try to convert a string to a string), it is pointless sinceAppendFormatwould do it anyway. Hence resharper tries to simplify your code here.