Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 3
    I've searched for answers along a very similar path, but it doesn't seem to lead anywhere. This appears to be a string class problem and hopefully not a more general issue. So right now I'm waiting for someone (Eric) with the source code to come along and explain what went wrong, and if anything else is effected. As a small benefit this discussion already settled the debate whether one should use string.Empty or ""... :) Commented Aug 9, 2012 at 4:01
  • Is the IL between them the same? Commented Aug 10, 2012 at 17:44
  • 49
    Good analysis! I will pass it along to the BCL team. Thanks! Commented Aug 13, 2012 at 15:49
  • 2
    @EricLippert and others: I discovered that code like typeof(string).GetField("Empty").SetValue(null, "Hello world!"); Console.WriteLine(string.Empty); gives different results on .NET 4.0 versus .NET 4.5. Is this change related to the change described above? How can .NET 4.5 technically ignore me changing a field value? Maybe I should ask a new question about this? Commented May 17, 2013 at 14:54
  • 4
    @JeppeStigNielsen: The answers to your questions are: "maybe,", "quite easily, apparently," and "this is a question-and-answer site, so yes, that's a good idea if you want an answer to your question better than 'maybe'". Commented May 17, 2013 at 15:26