How to swap an underscore for a space

When displaying a name of an enum item as a label, how do you replace an underscore with a space? because you must use an underscore for more that one word.

Iā€™d actually recommend you have an array of names, such that you write:

name = myEnumNames[enumVal];

because:

  1. It is then easy to change they player-visible names without changing all your code: because you find a better name; to translate to other languages; because you need other characters like ā€œ&ā€.
  2. Better performance: enum string conversion is surprisingly convoluted.

If you really must, use string.Replace :

name = enumVal.ToString().Replace("_"," ");