Link to home
Start Free TrialLog in
Avatar of mitesh114
mitesh114

asked on

C# Get and Set methods

Hi,
I have a class called Settings and I have this method in there:
public enum Scope
{
scopeone  = 0,
scopetwo = 1,
scopethree = 2                  
}
      
public Settings.Scope SelectScope
{
get{ return _selectScope; }
set{ _selectScope = value; }
}

I then have another method called MessageBox in which I want to display the scope value picked up from the dropdown.  How do I do this?
Avatar of Yttribium
Yttribium

public void MessageB()
{
      //For testing purposes:
      _selectScope = Scope.scopeone;
      MessageBox.Show(_selectScope.ToString());
}

.ToString()  will give a string name of the enum.  If you want the original number, you will have to create your own ToString() function and output the numeric value.
MessageBox.Show(Enum.GetName(typeof(Scope), _selectScope);
ASKER CERTIFIED SOLUTION
Avatar of Yttribium
Yttribium

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 mitesh114

ASKER

thanks for your help
No problem, thanks too!