public bool Active
{
get => active; //<---------there's a problem here-----
set
{
if (active == false && value == true)
Activate();
else if (active == true && value == false)
Suspend();
active = value;
}
}
CodePudding user response:
You don't have any variable declared called "active
".
Declare one:
private bool active;
then
public bool Active
{
get => active;
set
{
if (active == false && value == true)
Activate();
else if (active == true && value == false)
Suspend();
active = value;
}
}
To know more about c# properties read here.
CodePudding user response:
in C#4.0 you need write get{ return xxx; }
bool active;
public bool Active
{
get { return active; } //<---------there's a problem here-----
set
{
if (active == false && value == true)
Activate();
else if (active == true && value == false)
Suspend();
active = value;
}
}