Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does object @object mean

Tags:

c#

keyword

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. I haven't come across this before and can't seem to find any documentation for it.

What does this mean? Is it useful?

like image 859
Joey Ciechanowicz Avatar asked Nov 09 '11 17:11

Joey Ciechanowicz


People also ask

What does object object mean in JS?

The Object type represents one of JavaScript's data types. It is used to store various keyed collections and more complex entities. Objects can be created using the Object() constructor or the object initializer / literal syntax.

What is meant by object object?

1 : something material that may be perceived by the senses. 2 : something mental or physical toward which thought, feeling, or action is directed. object. noun.

What causes object object in JavaScript?

[object Object] is a string version of an object instance. This value is returned by a JavaScript program if you try to print out an object without first formatting the object as a string. It's no wonder developers get confused about this object: there are no error messages or warnings that tell us what is going on.

What does object keys mean?

Description. Object. keys() returns an array whose elements are strings corresponding to the enumerable properties found directly upon object . The ordering of the properties is the same as that given by looping over the properties of the object manually.


2 Answers

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:

  1. Interoperability issues with someone else's code: Someone else's code requires you to have a variable with a name of a reserved word. Maybe their code was written in a language with different reserved words than C#.
  2. Computer-generated code: It doesn't hurt to use an @ symbol. If you're paranoid about reserved word collisions, you might decide that all variables in your computer-generated code will use an @ symbol. Or maybe you are allowing a non-C# program to generate C# programs via a scripting language or whatever and you want to support variables named class.
like image 134
Brian Avatar answered Oct 15 '22 16:10

Brian


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. However prefix it with an @ character and it no longer is a keyword, just a valid variable name!

like image 37
Nathan Anderson Avatar answered Oct 15 '22 16:10

Nathan Anderson