I want to use an object (returned by framework, not in my control), myField
which has a property DisplayFormat
of type enum SPNumberFormatTypes
.
I want to assign the integer value of DisplayFormat as a string to an XmlAttribute
. Here is what I currently do:
myAttribute.Value = ((Int32)((SPNumberFormatTypes)field.DisplayFormat)).ToString();
One more possible way to achieve this is:
myAttribute.Value = ((Int32)Enum.Parse(typeof(SPNumberFormatTypes), field.DisplayFormat.ToString())).ToString();
I want to know if there is a simpler/cleaner way to achieve this?