У меня есть два класса:
Код: Выделить всё
public class TestClassProperties
{
public static class Foo1
{
public static int TestInt { get; set; } = 1;
public static string TestString { get; set; } = "Hello";
}
public static class Foo2
{
public static int TestInt { get; set; } = 2;
public static string TestString { get; set; } = "Hi";
}
public static class Foo3
{
public static int TestInt { get; set; } = 3;
public static string TestString { get; set; } = "Hey";
}
}
Код: Выделить всё
public class CallTestClass
{
string bar;
void PressKey(int numberPressed)
{
if (numberPressed == 1)
{
bar = Foo1.TestString;
Foo1.TestString = "Goodbye";
}
else if (numberPressed == 2)
{
bar = Foo2.TestString;
Foo2.TestString = "Goodbye";
}
else if (numberPressed == 3)
{
bar = Foo3.TestString;
Foo3.TestString = "Goodbye";
}
else
{
bar = "Nothing.";
}
Console.WriteLine("You said " + bar);
}
}
Любой помощь приветствуется.
Подробнее здесь: https://stackoverflow.com/questions/781 ... le-objects
Мобильная версия