[英]What does object @object mean
I've been playing around with events and delegates and need to raise my event asynchronously, thus I've been using: 我一直在玩事件和代表,需要异步提升我的事件,因此我一直在使用:
public event EventHandler OnHelloEvent;
public void Raise()
{
IAsyncResult syncResult = OnHelloEvent.BeginInvoke(this, new EventArgs(), null, null)
In Intellisense, the last null
is stated to be object @object
. 在Intellisense中,最后一个
null
被声明为object @object
。 I haven't come across this before and can't seem to find any documentation for it. 我之前没有遇到这个,似乎无法找到任何文档。
What does this mean? 这是什么意思? Is it useful?
它有用吗?
The @
sign can be thought of as "escape" character of sorts. @
符号可以被认为是各种各样的“逃脱”字符。 Since object
is a keyword in C#, you cannot use it as a variable name. 由于
object
是C#中的关键字,因此不能将其用作变量名。 However prefix it with an @
character and it no longer is a keyword, just a valid variable name! 但是用
@
字符作为前缀,它不再是关键字,只是一个有效的变量名!
@允许您使用保留关键字作为参数的名称。
That is the special character for escaping reserved words so that they can be used as identifiers. 这是转义保留字的特殊字符,以便它们可以用作标识符。
See Section 2.4.2 of the specification . 参见规范的第2.4.2节 。
Everyone answered "What does this mean?" 每个人都回答“这是什么意思?” but nobody answered "Is it useful?"
但没有人回答“它有用吗?”
In most cases, the answer is No . 在大多数情况下,答案是否定的 。 You should not use this.
你不应该使用这个。
There are a few special exceptions. 有一些特殊例外。 Off the top of my head:
脱离我的头顶:
class
. class
变量。 The @ symbol is just a prefix which allows you to use a reserved identifier as a variable name. @符号只是一个前缀,允许您使用保留的标识符作为变量名称。
So object @object
, defines a variable of type object called object. 因此
object @object
定义了一个名为object的对象类型的变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.