Reputation: 2956
Can some one explain why brackets are used instead of () in the single line of code below (c# codeBehind ASP.NET), and provide the technical document reference for this syntax
string cssFile = Request.Cookies["InquiryId"].Value;
Upvotes: 0
Views: 269
Reputation: 15722
Because Cookies is some kind of dictionary. Or more general: It defines an indexer property. Therefor the [] have to be used. () are used for a method call, which is just something different.
Upvotes: 1
Reputation: 6062
its a c# rather than VB.Net convention for accessing an array, nothing to do with asp.net really, rather the language choice for the code behind
Upvotes: 3
Reputation: 1039110
You may take a look at indexed properties. That's what is defined for the Cookies property.
Upvotes: 4