Spa*_*man 3 c# string string-interpolation
我一直在与同事讨论格式化以下代码的最佳方法。
return $" this is a really long string.{a} this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string.{b} this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string. this is a really long string.{c}";
Run Code Online (Sandbox Code Playgroud)
我的转到是:(预先指定点上的换行符,即大约 80 个字符)
return $" this is a really long string.{a} this is a really long string. this is a really long string." +
$" this is a really long string. this is a really long string. this is a really long string." +
$" this is a really long string. this is a really long string. this is a really long string." +
$" this is a really long string. this is a really long string. this is a really long string." +
$"{b} this is a really long string. this is a really long string. this is a really long string." +
$" this is a really long string. this is a really long string. this is a really long string.{c}";
Run Code Online (Sandbox Code Playgroud)
但是我担心我在运行时添加了不必要的工作。是这样吗?如果是这样,有更好的方法吗?
另外我不认为换行是一个好的答案><
| 归档时间: |
|
| 查看次数: |
892 次 |
| 最近记录: |