.net - What is the difference between C# & CLI when it comes in with value types and constructors? -


I read recently that C # and CLI define different ways to handle standard value types and constructors.

The CLI specification can not be a parameter constructor according to the value types, while the C # specifications are the default normative constructors in the type of value. If, according to the CLI specification, you need to make a value without specifying a parameter, with it there is a special instruction to do this.

So my questions are

  • Why C # designer deliberately distracts from the CII standard - what was the benefit of it, and why CLI would not give this functionality
  • In my limited experience, at any time, I allow myself to use 'special instruction', which was not initially intended, it is usually a part of a hack, how is it different?

In different places, about stability value To be considered, the point of being the creator of a parameter, you can always make a value without providing any argument, and this is true in both CLI and C #. In C #, you can only use standard constructor syntax:

  int x = new int ();  

There is a syntax for this and a different syntax for creating a "real" constructor.

Note that as C # 2, the default value operator that I think could be used instead:

  Int x = default (int); It seems close to generating IL, in fact I think that it is only possible that if we had to start with that, then C # would not have been "play" There are parametric constructors in all value types.  

On the other hand, consider Genetics: Public Zero Foo & lt; T & gt; () Where T: new () {tt = new T (); }

What price should be allowed for type? It is - but if C # did not allow , then it does not mean more to allow it in general ...

An interesting point that you might want to look deeper into - although C # will not allow you to define a custom value type parameter builder, you can do this in IL, and C # rarely Use it (and sometimes not) on the basis of context.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -