user3908357
user3908357

Reputation: 13

C# method definition is too complicated

When I looked at the documentation of the EditorFor method from the MVC library I came across this method definition :

public static MvcHtmlString EditorFor<TModel, TValue> {
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TValue>> expression,
    Object additionalViewData
}

It felt hard to understand for me but I think HTML helpers can be helpful so I want to understand and I also want to figure out its logic so that I can use it in other method definitions. I would be appreciated if you can help.

Edit: What can be a proper use of this method definition?

Upvotes: 0

Views: 178

Answers (1)

user1017882
user1017882

Reputation:

This is an extension method (which is why you see this and static). It takes two generic types (<TModel, TValue>) which you must specify on invoking the method, so that they can then be used/referred to throughout (including the other parameters e.g. HtmlHelper<TModel>). This method will return an object of type MvcHtmlString.

This is all you can gather from a signature. What it actually does and/or how it does it can only be told from it's contents.

Reading:

Extension methods:

http://msdn.microsoft.com/en-GB/library/bb383977.aspx

Generics:

http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx

Upvotes: 0

Related Questions