c# - dotnetcore GetTypeInfo() not defined on variables of type object? -


the code below stripped down version of original code demonstrates problem. in dotnetcore (1.0.1) .isenum property moved system.reflection. made changes work expected. however, 1 cannot make work of type object.

compiler throws error: c:\tmp\netcore\repro\program.cs(14,17): error cs0103: name 't' not exist in current context

public class program {     enum kleur {red, blue, green}      public static void main(string[] args)     {         object mytype = kleur.green;         if (mytype.gettypeinfo().isenum)         {             console.writeline("yes enum");         }     } } 

is there workaround test if object of type enum in dotnetcore? there specific reason why there no extension method type object (all other types needed seem work).

when moving type typeinfo, replacement .gettype() not .gettypeinfo(), it's .gettype().gettypeinfo(). that's because type not removed, instead split type, contains basic members, , typeinfo, has rest.

so, code should be:

object mytype = kleur.green; if (mytype.gettype().gettypeinfo().isenum) {     console.writeline("yes enum"); } 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -