KgO*_*ogs 1 c# code-formatting
我写了这行代码.这是不可读的.是否有巧妙的方法将其分解为多行代码<80或100个字符长度?
Console.WriteLine(String.Join("\n", testResults.Select(row => String.Join("|", row.Select(column => String.Format("{0,20}", column.ToString()))))));
我建议分离查询本身及其最终表示(控制台输出):
// Query: what to output
var testReport = testResults
.Select(row => String.Join("|", row
.Select(column => String.Format("{0,20}", column)))); // .ToString() is redundant
// Representation: how to output (print on the console in one go)
Console.WriteLine(String.Join(Environment.NewLine, testReport));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
805 次 |
| 最近记录: |