Cannot use String.Empty as a default value for an optional parameter

前端 未结 8 1625
生来不讨喜
生来不讨喜 2020-12-04 14:47

I am reading Effective C# by Bill Wagner. In Item 14 - Minimize Duplicate Initialization Logic, he shows the following example of using the new opt

8条回答
  •  被撕碎了的回忆
    2020-12-04 15:51

    I think the idea behind string.Empty is it enhances readability. It is not like newline where there is any difference between how it is represented on different platforms. It's ashame it can't be used in a default parameter. However, it will not cause any issues if you port between Windows and something like Mono on Linux.

提交回复
热议问题