开发者

Why is string.Empty readonly? [duplicate]

开发者 https://www.devze.com 2023-03-29 01:03 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Why isn't String.Empty a constant?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Why isn't String.Empty a constant?

...and not const?

I know its probably a useless question, but I'm sort of curious on the reasoning behind this one. An empty string is an empty string so I do not foresee many chances of string.Empty being anything else than "". So why make it readonly?

Is the开发者_运维问答re any other benefit I'm missing in not making it const?


It IS static.

public static readonly string Empty;


Readonly prevents it from being changed. Perhaps you mean "why isn't it a const"?

0

精彩评论

暂无评论...
验证码 换一张
取 消