0

I have some Enum like below

public enum A
    {
        A_1 = 1,
        A_2 = 2,
        A_3 = 3
    }

    public enum B
    {
        B_1 = 1,
        B_2 = 2,
        B_3 = 3
    }

I want to get the list from enum when passing its name as string, for example if i pass "A" then I wan tot get the values from enum A as a list, how can I achieve this?

Jiju John
  • 821
  • 3
  • 14
  • 35
  • Can you explain the reason why you want to do this? Where else are you using these enums? What will the list of the values be used for? – Logarr Mar 18 '20 at 13:52
  • 1
    Use [this](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.assembly.gettype?view=netframework-4.8) to obtain the enum by name. Use [this](https://stackoverflow.com/questions/105372/how-to-enumerate-an-enum) to get the list of values. – Robert Harvey Mar 18 '20 at 13:54
  • 1
    [How to get enum Type by specifying its name in String](https://stackoverflow.com/questions/25404237/how-to-get-enum-type-by-specifying-its-name-in-string) then [How to enumerate an enum](https://stackoverflow.com/questions/105372/how-to-enumerate-an-enum). – Drag and Drop Mar 18 '20 at 13:57
  • @RobertHarvey, found good dupe target for those 2. May you swing your hammer for both? – Drag and Drop Mar 18 '20 at 14:08
  • 1
    Does this answer your question? [How to get enum Type by specifying its name in String](https://stackoverflow.com/questions/25404237/how-to-get-enum-type-by-specifying-its-name-in-string) – Drag and Drop Mar 18 '20 at 14:08
  • I tried the answers in other posts, but I not getting the type , it is null – Jiju John Mar 18 '20 at 14:49

0 Answers0