In the following code: (WebMethod attribute in web service)
[WebMethod(CacheDuration = 300)]
public string GetData(string Id)
{
}
The intellisense for the WebMethod attribute class constructor shows the second overload as named parameters.
My doubt is that aren’t named parameter values specified using a colon (:) after the parameter name. How come an equal to operator is used here ?
Thanks.
You’re using a third syntax particular to attributes, in which you can specify fields to initialize on the attribute instance using a Name = Value syntax in the constructor call.
would work just as well, but it’s using standard named-parameter syntax instead of attribute field-initialization syntax. Remember that attributes were around before named parameters existed.