C# theory and the example plugin
Posted: Sat Nov 05, 2016 11:26 pm
Could anyone help me understand the following:
I’m trying to be a good boy and learn my C# theory. In classes we have instance variables and static variables.
An instance variable is declared if the static keyword in NOT used to declare it. Then we can only access / use that instance variable via an instance/object of the class.
So I create an instance variable:
bool beefyBool = true;
Then I declare a new instance of class UCCNCplugin:
UCCNCplugin beefysInstance = new UCCNCplugin();
To access beefsBool, don’t I have to do something like:
beefyInstance.beefysBool = false; // correct ?????????????
Yet in the plugin this is not so. For example the “firstrun” bool variable is accessed in
public void Loop_event()
{
if (firstrun)
{
firstrun = false;
…………………………….
…………………………….
…………………………….
}
(Tabbing / indentation disappears in the forum post).
There’s no instance accessing an instance variable. What am I not understanding.
Keith.
I’m trying to be a good boy and learn my C# theory. In classes we have instance variables and static variables.
An instance variable is declared if the static keyword in NOT used to declare it. Then we can only access / use that instance variable via an instance/object of the class.
So I create an instance variable:
bool beefyBool = true;
Then I declare a new instance of class UCCNCplugin:
UCCNCplugin beefysInstance = new UCCNCplugin();
To access beefsBool, don’t I have to do something like:
beefyInstance.beefysBool = false; // correct ?????????????
Yet in the plugin this is not so. For example the “firstrun” bool variable is accessed in
public void Loop_event()
{
if (firstrun)
{
firstrun = false;
…………………………….
…………………………….
…………………………….
}
(Tabbing / indentation disappears in the forum post).
There’s no instance accessing an instance variable. What am I not understanding.
Keith.