private void PrintString(StringBuilder sb, object arg) { IFormattable f; if (arg == null) PrintString(sb, "null"); else if ( (f = arg as IFormattable) != null) { string s = f.ToString(); // TODO: figure out what formatting spec to use for strings) PrintString(sb, s); } else PrintString(sb,arg.ToString()); }