Assume there's a base class
class base
{
int x, y;
}
And 3 derived singleton classes A, B, C with x, y initialized to some value.
example :
class A : base { x = 1; y = 0;}
class B : base { x = 0; y = 1;}
class C : base { x = 1; y = 1;}
Is there a way to Pass class as parameter to method and access that class's variable value. SO, One function that can update values for all 3 classes.
Intention :
int call (type classtype)
{
int xvalue = classtype.x;
int yvalue = classtype.y;
}
I've seen in some posts a mention of activator.CreateInstance(classtype) in How to pass a Class as parameter for a method? [duplicate]
But it doesn't answer how we can access variables of that class.