Link to home
Start Free TrialLog in
Avatar of panJacek
panJacek

asked on

Global variable passed as method parameter

Hello Experts :-)

I am newbie to C#, I have Delphi background so my approach is kind of Delphi style and maybe this is wrong for C#...

Anyway, here comes my question:

I want to create my own enum variable to be used across the whole application.

I created new static class, inside this class I created my enum variable.

I can use this variable inside other classes which is fine but I would also like to use it as a method parameter.

Compiler does not allow me to do it saying that this is a field not a variable.

How can I use my global field as variable then?

Thank you

panJacek
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

bring sample code of what you want to do here
ASKER CERTIFIED SOLUTION
Avatar of lenordiste
lenordiste
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of panJacek
panJacek

ASKER



public static class GlobalVariables
{
  public enum XYZ
  {
    x, y, z
  }
}

public class AnotherClass
{
  public AnotherClass(XYZ aParam)
  {
  }
}
   

It will not compile.

panJacek
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial