C# enums as function parameters?

后端 未结 7 1375
广开言路
广开言路 2021-01-04 00:10

Can you pass a standard c# enum as a parameter?

For example:

enum e1
{
    //...
}

enum e2
{
    //...
}

public void test()
{
    myFunc( e1 );
           


        
7条回答
  •  清酒与你
    2021-01-04 00:12

    You will have trouble if you try passing an enum directly to myFunc, as in the following example:

    enum e1 {something, other};
    myFunc(e1);  // Syntax error: "e1 is a type, but is being used like a variable"
    

提交回复
热议问题