¡@

Home 

c# Programming Glossary: myenum

Anyone know a quick way to get to custom attributes on an enum value?

http://stackoverflow.com/questions/17772/anyone-know-a-quick-way-to-get-to-custom-attributes-on-an-enum-value

an example. I have an enum with attributes public enum MyEnum CustomInfo This is a custom attrib None 0 CustomInfo This is.. from an instance public CustomInfoAttribute GetInfo MyEnum enumInput Type typeOfEnum enumInput.GetType this will be typeof.. Type typeOfEnum enumInput.GetType this will be typeof MyEnum here is the problem GetField takes a string the .ToString on..

C# int, Int32 and enums

http://stackoverflow.com/questions/1813408/c-sharp-int-int32-and-enums

and enums If int is synonymous to Int32 why does enum MyEnum Int32 Value 1 ...not compile Where as enum MyEnum int Value.. enum MyEnum Int32 Value 1 ...not compile Where as enum MyEnum int Value 1 will even though hovering the cursor over the int..

Can we define implicit conversions of enums in c#?

http://stackoverflow.com/questions/261663/can-we-define-implicit-conversions-of-enums-in-c

enums in c# something that could achieve this public enum MyEnum one 1 two 2 MyEnum number MyEnum.one long i number Edit If not.. that could achieve this public enum MyEnum one 1 two 2 MyEnum number MyEnum.one long i number Edit If not why not For further.. achieve this public enum MyEnum one 1 two 2 MyEnum number MyEnum.one long i number Edit If not why not For further discussion..

How to get C# Enum description from value? [duplicate]

http://stackoverflow.com/questions/2650080/how-to-get-c-sharp-enum-description-from-value

an enum with Description attributes like this public enum MyEnum Name1 1 Description Here is another HereIsAnother 2 Description.. allows me to write code like var myEnumDescriptions from MyEnum n in Enum.GetValues typeof MyEnum select new ID int n Name.. myEnumDescriptions from MyEnum n in Enum.GetValues typeof MyEnum select new ID int n Name Enumerations.GetEnumDescription n..

C# Iterating through an enum? (Indexing a System.Array)

http://stackoverflow.com/questions/482729/c-sharp-iterating-through-an-enum-indexing-a-system-array

Array values Enum.GetValues typeof myEnum foreach MyEnum val in values Console.WriteLine String.Format 0 1 Enum.GetName.. Console.WriteLine String.Format 0 1 Enum.GetName typeof MyEnum val val Or you can cast the System.Array that is returned string.. that is returned string names Enum.GetNames typeof MyEnum MyEnum values MyEnum Enum.GetValues typeof MyEnum for int i..

Why can't I declare an enum inheriting from Byte but I can from byte?

http://stackoverflow.com/questions/5005319/why-cant-i-declare-an-enum-inheriting-from-byte-but-i-can-from-byte

from byte If I declare an enum like this ... public enum MyEnum byte Val1 Val2 ... it's working. If I declare an enum like this.. working. If I declare an enum like this ... public enum MyEnum System.Byte Val1 Val2 ... it's not working. The compiler throw..

add values to enum

http://stackoverflow.com/questions/55375/add-values-to-enum

lead to problems with polymorphism. Say you have an enum MyEnum with values A B and C and extend it with value D as MyExtEnum...

Anyone know a good workaround for the lack of an enum generic constraint?

http://stackoverflow.com/questions/7244/anyone-know-a-good-workaround-for-the-lack-of-an-enum-generic-constraint

exist in C#3 return input matchTo 0 So then I could do MyEnum tester MyEnum.FlagA MyEnum.FlagB if tester.IsSet MyEnum.FlagA.. return input matchTo 0 So then I could do MyEnum tester MyEnum.FlagA MyEnum.FlagB if tester.IsSet MyEnum.FlagA act on flag.. matchTo 0 So then I could do MyEnum tester MyEnum.FlagA MyEnum.FlagB if tester.IsSet MyEnum.FlagA act on flag a Unfortunately..

Dynamic enum in C#

http://stackoverflow.com/questions/725043/dynamic-enum-in-c-sharp

and saved to disk. AssemblyName name new AssemblyName MyEnums AssemblyBuilder assemblyBuilder currentDomain.DefineDynamicAssembly.. Define a dynamic module in MyEnums assembly. For a single module assembly the module has the same.. name.Name .dll Define a public enumeration with the name MyEnum and an underlying type of Integer. EnumBuilder myEnum moduleBuilder.DefineEnum..

C# Iterating through an enum? (Indexing a System.Array)

http://stackoverflow.com/questions/482729/c-sharp-iterating-through-an-enum-indexing-a-system-array

code Obtain the string names of all the elements within myEnum String names Enum.GetNames typeof myEnum Obtain the values of.. elements within myEnum String names Enum.GetNames typeof myEnum Obtain the values of all the elements within myEnum Array values.. typeof myEnum Obtain the values of all the elements within myEnum Array values Enum.GetValues typeof myEnum Print the names and..

add values to enum

http://stackoverflow.com/questions/55375/add-values-to-enum

it with value D as MyExtEnum. Suppose a method expects a myEnum value somewhere for instance as a parameter. It should be legal..

Dynamic enum in C#

http://stackoverflow.com/questions/725043/dynamic-enum-in-c-sharp

name MyEnum and an underlying type of Integer. EnumBuilder myEnum moduleBuilder.DefineEnum EnumeratedTypes.MyEnum TypeAttributes.Public.. foreach MyDataSet.MyDataRow row in myData.Rows myEnum.DefineLiteral row.Name row.Key Create the enum myEnum.CreateType.. myEnum.DefineLiteral row.Name row.Key Create the enum myEnum.CreateType Finally save the assembly assemblyBuilder.Save name.Name..

Instantiate an object with a runtime-determined type

http://stackoverflow.com/questions/981330/instantiate-an-object-with-a-runtime-determined-type

to that type. Something like this static void castTest myEnum val Call a native function that returns a pointer to a structure..