“.@checked”的含义和名称是什么?
What is ".@checked" meaning and called?
当我阅读 C# 源代码时,我看到一行
return new Form(ElementType.Checkbox, ((IHTMLInputElement)htmlElement).@checked);
但我无法通过关键字 .@checked
找到它。
能否请您告诉我 .@checked
的名称及其含义?
更新答案
首先,感谢@Yeldar Kurmangaliyev、@Erik Funkenbusch 和@TcKs。
其次,很抱歉重复 post。因为我用“.@checked”搜索,什么也没看到。
最后,我明白了 @
符号帮助定义了一个名称与 C# keyword
相同的变量,就像这样:
string @string = "This is a string";
string str = @string; // str = "This is a string"
checked
是 keyword in C#,因此名称必须以 @
为前缀,如文档所述:
Keywords are predefined, reserved identifiers that have special
meanings to the compiler. They cannot be used as identifiers in your
program unless they include @ as a prefix. For example, @if is a valid
identifier but if is not because if is a keyword.
所以 ((IHTMLInputElement)htmlElement).@checked)
意味着访问 class 实例上的 checked
成员实现 IHTMLInputElement
.
当我阅读 C# 源代码时,我看到一行
return new Form(ElementType.Checkbox, ((IHTMLInputElement)htmlElement).@checked);
但我无法通过关键字 .@checked
找到它。
能否请您告诉我 .@checked
的名称及其含义?
更新答案
首先,感谢@Yeldar Kurmangaliyev、@Erik Funkenbusch 和@TcKs。
其次,很抱歉重复 post。因为我用“.@checked”搜索,什么也没看到。
最后,我明白了 @
符号帮助定义了一个名称与 C# keyword
相同的变量,就像这样:
string @string = "This is a string";
string str = @string; // str = "This is a string"
checked
是 keyword in C#,因此名称必须以 @
为前缀,如文档所述:
Keywords are predefined, reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in your program unless they include @ as a prefix. For example, @if is a valid identifier but if is not because if is a keyword.
所以 ((IHTMLInputElement)htmlElement).@checked)
意味着访问 class 实例上的 checked
成员实现 IHTMLInputElement
.