Я создал библиотечный класс, где ...
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?
...
}
}
}
}
Вот ошибка, которую я получаю:
Cannot access a nonstatic member of outer type
"MyCircuitLibrary.CircuitLibrary.SerialCommands" via nested type
"MyCircuitLibrary.CircuitLibrary.SerialCommands.SensorSettingsCommands"
Похоже, что он ищет (и нашел?) Sensor
в SerialCommands
? Но если я изменю его на CircuitLibrary.Sensor
, теперь он знает, что он находится в CircuitLibrary? Когда я щелкаю правой кнопкой мыши и выбираю «Перейти к определению», он находит все в порядке и не говорит «Не удалось найти Sensor
в SerialCommands
» Если бы кто-то мог помочь объяснить, что происходит, я был бы признателен.
Спасибо!