using these classes
public class Parent
{
public int parentInt;
}
public class Child: Parent
{
public string childString;
public Child(string passedString, int passedInt)
{
childString = passedString
parentInt = passedInt
}
}
I want to write a function that does stuff like this:
public static void DoSomething(Parent passedParent, Type passedChildType)
{
ScreenRecorder.Start()
//print all of parents properties
//print all of the specific child's properties if possible
}
I want this function to be able to handle any type of child I create in the future, How can I make it so that I can dynamically rebuild the child's properties inside the function?
Here is an example of the method being called:
public static int dostuff(string s)
{
int functionReturnValue = 0;
switch (s)
{
case "":
functionReturnValue = 0;
break;
case "7/8":
functionReturnValue = 14;
break;
case "15/16":
functionReturnValue = 15;
break;
default:
Child ex = new Child("Blue", 1);
Library.Handler.Process(ex, typeof(Child));
break;
}
return functionReturnValue;
}
What can I pass in or do inside the Dosomething method to rebuild the child object attributes?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…