There are MANY overloads to UpdateModel in the ASP.NET MVC controller class.
Some of them are generic, and some aren’t.
Obviously I want to use the generic version but I don’t see what it actually does for me? Isn’t UpdateModel just a way to populate the properties using reflection.
So what’s the difference between this:
UpdateModel<ContestModel>(model);
vs.
UpdateModel(model);
Is reflection just a bit faster if it knows the type – or is there another reason?
There does not exist any
UpdateModeloverload without the generic type signature. What you are seeing, is how smart the compiler is. When calling a method with a generic signature and one of the parameters are that same generic type, the compiler infers the type for you.In other words, those two examples you posted, are exactly the same in the eyes of the compiler.