We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://michaelscodingspot.com/debug-linq-in-csharp/
The text was updated successfully, but these errors were encountered:
Linq 是 C# 语言中的特色,我们通常会使用链式的方式将一连串的 Linq 语句组合起来达到想要的目的。但是这种方法有一个问题是调试起来比较麻烦,那么有什么办法解决这个问题呢?
Linq
QuickWatch 是 C# 中高级调试功能,可以在断点处,右键选择 Quickwatch 方式,在 QuickWatch 中输入查询语句,可以动态显示查询结果。
QuickWatch
C#
Quickwatch
当我们使用断点的功能的时候,可以选择断点发生的条件,或者每次执行的额外的操作,比如日志。
在 Debug 模式下,将调试信息输出到 Debug 窗口
Debug
public static IEnumerable<T> LogLINQ<T>(this IEnumerable<T> enumerable, string logName, Func<T, string> printMethod) { #if DEBUG int count = 0; foreach (var item in enumerable) { if (printMethod != null) { Debug.WriteLine($"{logName}|item {count} = {printMethod(item)}"); } count++; yield return item; } Debug.WriteLine($"{logName}|count = {count}"); #else return enumerable; #endif }
OzCode
OzCode 是 Visual Studio 的插件,它可以辅助我们进行 debug, 在 Linq 中,对于每个查询,可以显示其操作之后的数据集。
Sorry, something went wrong.
No branches or pull requests
https://michaelscodingspot.com/debug-linq-in-csharp/
The text was updated successfully, but these errors were encountered: