Public static bool Isdefined (Type enumtype, object Value) {If (enumtype = NULL) {Throw new argumentnullexception ("enumtype");} If (! (Enumtype is runtimetype) {Throw new argumentexception (environment. getresourcestring ("arg_mustbetype"), "enumtype");} If (! Enumtype. isenum) {Throw new argumentexception (environment. getresourcestring ("arg_mustbeenum"), "enumtype");} If (value = NULL) {Throw new argumentnullexception ("value");} type Type = Value. GetType (); If (! (Type is runtimetype) {Throw new argumentexception (environment. getresourcestring ("arg_mustbetype"), "valuetype");} type Underlyingtype = Getunderlyingtype (enumtype); If (type. isenum) {type Type3 = Getunderlyingtype (type); If (type! = Enumtype) {Throw new argumentexception (string. format (environment. getresourcestring ("arg_enumandobjectmustbesametype"), type. tostring (), enumtype. tostring ();} type = type3;} else if (type! = Underlyingtype) & (type! = Stringtype) {Throw new argumentexception (string. format (environment. getresourcestring ("arg_enumunderlyingtypeandobjectmustbesametype"), type. tostring (), underlyingtype. tostring ();} If (type = stringtype) {string [] Names = Gethashentry (enumtype). Names; For (int I = 0; I <names. length; I ++) {If (Names [I]. equals (string) value) {return true ;}} return false ;} ulong [] Values = Gethashentry (enumtype). Values; If (type! = Inttype) & (type! = Typeof (short) & (type! = Typeof (ushort) & (type! = Typeof (byte) & (type! = Typeof (sbyte) & (type! = Typeof (uint) & (type! = Typeof (long) & (type! = Typeof (ulong) {Throw new invalidoperationexception (environment. getresourcestring ("invalidoperation_unknownenumtype");} ulong Num2 = Touint64 (value); Return (binarysearch (values, num2)> = 0 );}