c# - What is System.Void? -


I know that the method declared with zero does not return anything.

But it seems that in C # there is more zero and there is only one keyword, but a real type. There is an alias for zero System.Void as int which is System.Int32 .

Why is not there permission to use that type of thing? It does not make any sense, but it only has some ideas about the argument.

Neither

  var nothing = new system Weed ();   

(which says I should use zero (not alias?))
not

  var nothing = new zero ();   

Compiles.

It is not possible to do anything like this:

  Do not give me zero () {} give zero) {nothing to return); }   

Then what is the point with System.Void ?

to:

/ Code> structure is used in the system. Reflection namespace, but rarely useful in a normal application zero structure does not have any member of all types, from the object class Receive.

There is no reason to use it in the code.

In addition to:

  var nothing = new zero ();   

This does not compile for me

Update:

One method void Foo () does not return, what does this mean? anything. System.Void is such that if you ask (through reflection), "what method is the type of return method?", You can get the answer typeof (System.Void) Are . There is no technical reason for this, instead of null can not be returned, but this reflection will present a special case in the API, and if possible, special cases should be avoided.

Finally, this expression is not legal for any program involving typeof (System.Void) . However, this is an compiler-applicable restriction, CLR is not one. In fact, if you try the allowed typeof (zero) and see its value in the debugger, you will see that this is the same value if it is the typeof (System.Void) Were legal.

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -