I have created a library class where...
public class CircuitLibrary
{
// Fields, properties, methods, etc.
...
// Nested classes.
public class Sensor
{
// Enums.
public enum Sensors { Sensor1, Sensor2, Sensor3, ... };
...
}
public class SerialCommands
{
// Fields, properties, etc.
...
// Nested classes.
public class SensorSettingsCommands
{
// Fields, properties, etc.
...
public void SomeMethod()
{
...
if( Sensor.Sensors.IsOn ) // Doesn't like this. OK if I change to CircuitLibrary.Sensor.Sensors.IsOn. Why?
...
}
}
}
}
Here is the error I receive:
Cannot access a nonstatic member of outer type
"MyCircuitLibrary.CircuitLibrary.SerialCommands" via nested type
"MyCircuitLibrary.CircuitLibrary.SerialCommands.SensorSettingsCommands"
So it looks like it is searching for (and found?) Sensor in SerialCommands? But if I change it to CircuitLibrary.Sensor it now knows it is in CircuitLibrary? When I right-click and "Go to definition" it finds it okay and doesn't say "Couldn't find Sensor in SerialCommands". If someone could help explain what is going on I would appreciate it.
Thanks!