Many times in the past, I’ve written statements like the following:


myString.Replace(" "" ");

Every time, I hate myself for doing it. Why? Because string.Replace() doesn’t change anything. It has no side effects. Strings are immutable, so this call just returns a new value – which I don’t use.

Lately I’ve found the same problem with DateTime – calling, say, AddSeconds() on it does not, in fact, add seconds to the particular object – it creates a new one.

I don’t know if it’s good or bad, or maybe someone somewhere decided that all structs are immutable. But I for one am very tempted to write a ReSharper demon that checks for such usage and advises me of potentially pointless calls.