Of course, I had to verify that enum parsing really works as they say it does (see previous post). So I wrote a little unit test. All tests in this class pass:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTests
{
[TestClass]
public class EnumParsingTest
{
enum Test
{
Foo = 10,
Bar = 20
}
[TestMethod]
public void ParseStringValue()
{
Assert.AreEqual(Test.Foo, Enum.Parse(typeof(Test), "Foo"));
}
[TestMethod]
public void ParseIntValue()
{
Assert.AreEqual(Test.Foo, Enum.Parse(typeof(Test), "10"));
}
[TestMethod]
public void ParseUnrelatedIntValue()
{
Assert.AreEqual((Test)40, Enum.Parse(typeof(Test), "40"));
}
}
}