foreach to from..select (I)

 

Build a coma-separated list of the string representation of an array of objects, rendering null values as "null", string values with quotes ( i.e. 15, true, "foo", null ) and everything else using object.ToString():

foreach:

List<string> values = new List<string>(invocation.Arguments.Length);
foreach (var x in invocation.Arguments)
{
values.Add(x == null ?
"null" :
x is string ?
"\"" + (string)x + "\"" :
x.ToString()
);
}

string ...

Read full article

No Comments