What’s a more elegant way of having the code below where i want to return a derived class based on the type of another class.
if (option_ is Rectangle) { modelInputs = new Foo(); } else if (option_ is Circle) { modelInputs = new Bar(); } else if (option_ is Triangle) { modelInputs = new Bar2(); }
Have Rectangle, Circle and Triangle implement IHasModelInput:
then you can do