'How to auto update class values when selected?
I have Server1.cs and Server2.cs in project. How can I update all the values in MainServer.cs class when the combobox selects to 'Server1'? (Like copy Server1.cs to MainServer.cs). I want that idea but I searched in Google, not found.
Server1.cs Class:
class Server1
{
public static int ServerID = 0x1;
public static int ServerPointer = 0x54A;
public static int ServerOffset1 = 0x5FF;
public static int ServerOffset2 = 0x604;
public static int ServerOffset3 = 0x66A;
}
Sever2.cs Class:
class Server2
{
public static int ServerID = 0x3;
public static int ServerPointer = 0x53A;
public static int ServerOffset1 = 0x56F;
public static int ServerOffset2 = 0x614;
public static int ServerOffset3 = 0x68A;
}
MainServer.cs Class:
class MainServer
{
public static int ServerID = Server1.ServerID or Server2.ServerID;
public static int ServerPointer;
public static int ServerOffset1;
public static int ServerOffset2;
public static int ServerOffset3;
}
When selected combobox:
if (comboBox1.SelectedItem.ToString() == "Server1")
{
MainServer = Server1();
}
else if (comboBox1.SelectedItem.ToString() == "Server2")
{
MainServer = Server2();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|