I have XML that contains several flags, some of them are unsigned 32-bit integers, and others are unsigned 64-bit integers. Some of them are written in a comma-separated list, while others are in hexadecimal style.
See this example:
<Color>Blue,Red</Color> <Color>0xC</Color>
Since I do not want to write a method to parse each enumeration, I decided to use a general method. But Visual Studio will not let me create a solution. Here is my method:
public static T ParseFlags<T>(string value) where T : struct { T result = (T)((object)0); string[] array;
The error message I get is:
Error 1 Operator '| = 'cannot be applied to operands of type "T" and' T '
Is there any way to do this?
source share