c# - “this” in function parameter in web api -
i developing web api, have created htmllhelper class, , see declarations like:
public static string getcountrydomain(this system.web.mvc.htmlhelper htmlhelper, area area) { //body }
in controller want call above function. expects 2 parameters.
htmlhelper.getcountrydomain(area_id);
can explain first parameter need pass in order call above function?
this
keyword marks extension method. there 2 ways of calling it:
- you can call if instance method on
htmlhelper
, or - you can call normal
static
method passing 2 parameters.
the first way more common (after all, that's point of making method extension)
// prepare parameters htmlhelper helper = ... area area = ... // call function string countrydomain = helper.getcountrydomain(area);
Comments
Post a Comment