I have 3 class like ClassVersion1, ClassVersion2 and ClassVariables. ClassVariables is for reach variables of other class from Form.
İn my opinion were these;
if(version == 1)
{
ClassVersion1 clss = new ClassVersion1();
}
else
{
ClassVersion2 clss = new ClassVersion2();
}
clss.vars.variable1 = 3;
clss.vars.variable2=5;
clss.DoSomething();
But I have to call functions and variabless into the if condition(two objects with same name, different class). I want to Create object into condition and use out of condition.
How can I do this?
You could use an interface:
Then use it like this: