View Single Post
  #5 (permalink)  
Old April 21st, 2007, 03:56 AM
joefawcett's Avatar
joefawcett joefawcett is offline
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

But in C# the Parse method returns a typed representation of the Enum given its value or name.
So if you want to supply 4 and get back an object that has one property, West that has a value of 4 then do:
Code:
Parse: function(enumtype, enumvalue){
    for (var enumName in enumtype){
        if(enumtype[enumName] == enumvalue)
        {
            var o = {};
            o[enumName] = enumvalue;
            return o;
        }
    }
}
--

Joe (Microsoft MVP - XML)
Reply With Quote