Talk:Comparison of C Sharp and Java: Difference between revisions

Content deleted Content added
Useerup (talk | contribs)
Line 37:
</pre>
More than that, if you try to code the same examples provided by Microsoft to explain how Value Types are working, these examples also work in Java, with an almost identical syntax.[[User:Hervegirod|Hervegirod]] ([[User talk:Hervegirod|talk]]) 21:41, 24 June 2011 (UTC)
 
You are mistaken, value types are not boxed/unboxed in .NET like they are in Java. This would be the code in C#:
<pre>
var list = new List<int>();
list.add(2);
int value = list[0]
</pre>
And it would ''not'' involve the relatively expensive boxing and unboxing conversions. This goes for any primitive and value type (primitive types are just a subset of value types). <code>int</code> is a value type, and in C# you can define new value types. Only when value types are treated ''like objects'' (reference types) are they boxed. You may declare arrays of custom value types and the array will contain the actual values not a boxed references to values. [[User:Useerup|Useerup]] ([[User talk:Useerup|talk]]) 23:23, 26 June 2011 (UTC)
 
== Is this entire article directly lifted from some page at microsoft.com? ==