I stumbled upon this code and I am curious as to what use may the string.Empty part have in it. Is it as completely useless as it seems? Am I missing something?
System.Windows.Forms.ToolStripButton m_button;
int errorCount;
...
m_button.Text = string.Empty + errorCount + " error(s)";
It looks like it’s to allow
errorCountto be implicitly cast tostringrather than having to do an explicit cast – i.e.errorCount.ToString(). However, as you point out, the implicit cast is perfectly valid, so it must be the result of some code review, old code being changed, or StyleCop type code “cleaner” being run.It’s bad programming really.
A better solution might be to do: