Enum cast

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
CyborgDE
Posts: 75
Joined: Wed Aug 12, 2015 9:21 pm

Enum cast

Postby CyborgDE » Tue Oct 06, 2015 2:05 am

Hello,

works well under windows but not under javascript (beta 5) :

Code: Select all

        public override ValueType ConvertFromString( string input, Type toType )
        {
         if (toType.IsEnum)
#if CSHTML5
         {
            var vals = Enum.GetValues(toType);
            int i = 0;
            foreach (var val in vals)
            {
               if (val.ToString() == input)
               {
                  return val as ValueType;
               }
               i++;
            }
            throw new ArgumentException("ENum value not found " + input + " in " + toType.ToString());
         }
#else
         return (Enum.Parse(toType, input, false)) as ValueType;
#endif
        }

the cast destroys the enum type ...

If I move to code to the calling function, it works ...

Reagards, Uwe

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 33 guests

 

 

cron