有人可以解释一下为什么在下面的单行代码(ASP.NET后面的C#代码)中使用括号而不是(),并提供此语法的技术文档参考吗?
string cssFile = Request.Cookies["InquiryId"].Value;
You may take a look at indexed properties . That's what is defined for the Cookies property.
您正在查看的[]
语法称为索引器 (msdn链接)。
它的ac#而不是用于访问数组的VB.Net约定,实际上与asp.net无关,而是背后代码的语言选择
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.