views:

227

answers:

1

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?

+4  A: 

There does not exist any UpdateModel overload 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.

Thomas J
ahh that makes sense. i guess i've missed that if it appears anywhere else in the framework. thanks
Simon_Weaver