c# - How do i dynamically cast a child class from its parent class? -
What I'm trying to do here is that I have a class with the parentform one of its essentials Form has been added to the class with 2 things. Then every and form I get it near ParentForm so I like Now I say that I have both F1 and F2 A button is F3 and the F3 form constructor looks like this: I use the variables back to the original form (in this case either F1 or Now here's my problem. I'm talking like this for now: So I am making a check for every parent, how can I do this dynamically? Some such But most of it does not work Has anyone got the solution? I'm not sure that this is the best solution, but I How to do this: and so on
class f1 : Parentform class F2: ParentForm class f3: ParentForm etc ...
public parent (parent parent parent) < / Pre>
if (parent.GetType () == typeof (f1)) {((f1) parent) .list.Add ("A"); } And if (Parents getType () == Type (f2)) {((2) parent) .list.Add ("a"); }
(parent.GetType () parent) .list.Add ("a");
Abstract class ParentForm {... public abstract void update
Comments
Post a Comment