Linqpad增强版的Console.WriteLine非常棒。然而,我如何才能做一个对象的标准Console.WriteLine呢?
发布于 2012-10-06 14:09:13
Debug.WriteLine
也会做到这一点。
发布于 2012-10-04 11:26:08
哈,现在很明显-放在一个显式的ToString中
Console.WriteLine(x.ToString());
发布于 2016-04-29 10:43:15
您还可以将这些方法添加到“我的查询”窗格中的"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);
}
https://stackoverflow.com/questions/12726207
复制