Linqpad的强化版Console.WriteLine非常好用。但是,我如何对一个对象进行标准的Console.WriteLine输出?
Linqpad的强化版Console.WriteLine非常好用。但是,我如何对一个对象进行标准的Console.WriteLine输出?
Debug.WriteLine
也能解决问题。
Console
颜色 - MaslowConsole.WriteLine(x.ToString());
你也可以将这些方法添加到“My Queries”窗格中的“MyExtensions”文件中。这样,你就可以使用.DumpToString而不是.Dump。也许它们应该被重命名为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);
}
你也可以这样做
x.Dump();
这将使用LinqPad API来美化输出。