3
I have a select where I have some options
- Teste1
- Teste2
- Teste3
I have a model for each option
public class Teste1() {
//atributos e métodos
}
I would like to receive this string ex in a certain part of my system: "Teste1"
and create a Teste1 object
something like:
var objeto = new "Teste1"
That is to generate an object from its name
Are you sure you need this? In general you don’t need it, it has much better mechanisms. I could indicate something if I knew the problem you’re trying to solve. This is already common practice in dynamic language, even worse in static language. It is often done to save some typing and this is not appropriate. It would complicate the application without gain. On the contrary.
– Maniero
Of course please, the problem is that I will have an isValid method in each model, teste1, teste2 , and in a controller I need to receive from the view which face I want to validate, however in my view I only have how to pass the name of the class because it will come from the choice of the user there on the screen, then I would only worry about creating the instance from the choice of it, and call the isValid
– Jhonatan Jorge de Lima