It is either too smart or not smart enough, at 62.784%. For unknown reasons, the product guide decided that they want to rename some of our enumeration values ββand how they are serialized. After several builds, they decided that they would be backward compatible - that is, read and process the old serializations with the new values.
I thought that I would first try to declare a new name in the enumeration, and then declare it OldName = NewNameimmediately as a synonym, hoping that the equivalence will be worked out in the wash in favor of the first declaration, and it will automatically transfer the old one to the new one using Enum.Parse.
I developed a small sample application, for example:
public enum syns
{
Zero,
One,
Two,
Three = Two,
Four,
};
public string SynTest()
{
string result;
syns synTest2 = (syns)syns.Two, synTest3;
bool okay = Enum.TryParse<syns>("Three", out synTest3);
result = (okay).ToString() + "," + (synTest2 == synTest3).ToString() + "," + synTest2.ToString() + "," + synTest3.ToString() + ",";
synTest3 = (syns)Enum.Parse(typeof(syns), "Three");
result += synTest3.ToString();
return result;
}
, . "Three" , , Two. Yay.
, ( , / ..). , .
, , , - , . QA () "Three" Three ( ), Two.
- , , 50% , , , ( ) 50% .
test.aspx, test.aspx , . test.aspx , .
- , , enums?
- , ? 4.5.1, , , , , , .
- , , test.aspx, , , .