问题
Linqpad's souped-up Console.WriteLine is awesome. However, how can I do a standard Console.WriteLine of an object?
回答1:
Debug.WriteLine
will also do the trick.
回答2:
Huh, obvious now - put in an explicit ToString
Console.WriteLine(x.ToString());
回答3:
You can also add these methods to your "MyExtensions" file in the "My Queries" pane. This way you can use .DumpToString instead of .Dump. Maybe they should be renamed DumpDebug ...
// Write custom extension methods here. They will be available to all queries.
public static void DumpToString<T>(this IEnumerable<T> list)
{
list.ToList().ForEach(x => Debug.WriteLine(x));
}
public static void DumpToString(this object o)
{
Debug.WriteLine(o);
}
public static void DumpToString(this string o)
{
Debug.WriteLine(o);
}
回答4:
You can also do
x.Dump();
Which will use the LinqPad API to pretty format the output.
来源:https://stackoverflow.com/questions/12726207/canonical-console-writeline-in-linqpad