What is the "generic" type for an enum array?

I have a method that would like to take an array of user Enumtypes as a parameter .

Something that will look like :

public void DoSomething(WhatDoIPutHere[] parameters)

I would like to pass to this method either a Enum1[], or Enum2[], where Enum1and Enum2- 2 Enum.

What do i need to use instead WhatDoIPutHere?

I would expect to define the DoSomething signature as Enum[]somehow Enum- this is the base class for Enum types (right?):

public void DoSomething(Enum[] parameters)

but he gives:

cannot convert from 'xxx.Enum1 []' to 'System.Enum []'

I also tried to define it as object[], but I get the same compiler error.

, , , ...

+3
1

. . :

public void DoSomething<T>(T[] parameters) where T : struct, System.Enum

... ( ).

:

  • :

    public void DoSomething(Array parameters)
    
  • :

    public void DoSomething<T>(T[] parameters)
    
  • Unconstrained Melody, , IL- .

+6

All Articles