I often use String.Empty for a placeholder, which equates to "". So my question, why does a const not like String.Empty? They compile identically.
// Good
private const string example = "";
// Bad
private const string example = String.Empty;
What in String.Empty makes it not able to be used with a const.
Emptyisn't itself a constant, so as far as the compiler is concerned it could resolve to anything. And aconstneeds to guarantee at compile time what it's value will be. The literal""provides that guarantee.String.Emptyvs.""... This question seem to be just about "why readonly can't be use as const" (approximately stackoverflow.com/questions/755685/static-readonly-vs-const) OR "whyString.Emptyis not const". Some clarification from Greg may help.