.NET
Microsoft Technologies based on the .NET software framework.
4,090 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
///////////////// enum def ///////////////////////////////////
public enum MyEnum1 { m1, m2, m3, ... ,Help };
public enum MyEnum2 { m1, m2, m3, ... ,Help };
public enum MyEnum3 { m1, m2, m3, ... ,Help };
.
.
.
public enum MyEnum99 { m1, m2, m3, ... ,Help };
/////////////// use case /////////////////////////////////////
void foo<TEnum>( TEnum x) where TEnum : struct
{
// TO DO
if ( x == Help ) // error
// do stuf with TEnum
////////////////////////////////////////////////////////////////
i have many enums most of them have element name "Help",
is there a way to check if a generic var x is "Help" without hard coding casting all 99+ enum ?
thanks in advance, any idea will be appreciated.
For example:
if( Enum.GetName( typeof( TEnum ), x ) == "Help" )
{
. . .
}