I'm just trying to quickly debug a webservice by printing out the contents of an int and string array. Is there anyway to do this in one method?
I tried
public static string ArrayToString(object[] array)
{
StringBuilder sb = new StringBuilder();
foreach (Object item in array)
{
sb.Append(item.ToString());
sb.Append(" ");
}
return sb.ToString();
}
But this chokes when I try and send it a primative array (int[]) due to it not being an Object.
Which I find strange as sending an int to the method below works
static void PrintObject(object obj)
{
Console.WriteLine(obj.ToString());
}
Is there anyway to do this in one method or am I just going to have to man up and create two separate methods?
Of course whether I should be using arrays at all is questionable, but the web service is already in place.
See also: