I was wondering if its possible to parse strings to defined values for uint. Something similar to http://msdn.microsoft.com/en-us/library/essfb559.aspx. So if I have the following declarations:
public const uint COMPONENT1 = START_OF_COMPONENT_RANGE + 1;
public const uint COMPONENT2 = START_OF_COMPONENT_RANGE + 2;
public const uint COMPONENT3 = START_OF_COMPONENT_RANGE + 3;
And have an xml file defined the following way:
<node name="node1" port="12345">
<component>COMPONENT1</component>
<component>COMPONENT2</component>
</node>
I want to be able to parse the string COMPONENT1 to the uint value of COMPONENT1. This to have easier overview of the xml file instead of the numbers 5001, 5002 f.e.
I assume that defining a dictionary or array could solve it but that leaves extra code.
If you don’t need the constants you could go with a
enum-type together with it’sToStringandParsemethods.If you really need the constants than you will have to write a big
switchstatement.