c# - Exception.Message 中的换行符

标签 c# string exception-handling

我正在扩展 Exception 以在 Message 属性上实现一个 setter。这很好用。但不知何故:

CustomException.Message = "Test" + Environment.NewLine + "Test Again";

变成这样:

"Test\r\nTest Again"


我也试过这个,但没有运气:

CustomException.Message = @"Test

Test Again";


有什么想法吗?

最佳答案

Environment.NewLine IS \r\n(至少在 Windows 上,无论如何......)

关于c# - Exception.Message 中的换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1404557/

相关文章:

c# - Windows RT 应用程序中的图像闪烁

c# - 有没有办法用 EF Core 映射复杂类型

string - 为什么 GDB 认为我的 Fortran 字符串是 ~4GiB

python - 在 Pandas 拆分中使用 str

Java 8 - 异常关闭流?

c# - 在类型 Nullable<Int32> 和 Int32 之间未定义 Equal

c# - 如何避免项目打开时所有代码节点都展开?

java - 我在java中看不到子字符串方法

c++ - C++ 终止处理程序何时才是正确的事情 (TM)?

ruby - 在 Ruby 中自动记录异常