Changing the Enum.Format Separator

Enum.Format (or <enum> .ToString ()) has an optional format that allows you to specify various formatting options. For "G" or "F" with a bit flag enumeration, it displays a "list of the names of these constants separated by a separator."

At least on my system, I get a comma separated list. I would like to know if you can change this separator either using the format string, or using some other method that I have not come across. (In particular, I need a channel-delimited list.)

Of course, I can always just replace the line in the output, but if it is possible to change the separator in advance, so much the better.

+3
source share
1 answer

I don’t think so, according to http://msdn.microsoft.com/en-us/library/c3s1ez6e.aspx they will be separated by commas. You will need to do the replacement when converting with a comma. You can do something like this:

var sb = new StringBuilder(YourEnum.ToString("F"));
sb.Replace(",", "|");
+3
source

Source: https://habr.com/ru/post/1774656/


All Articles