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

Content deleted Content added
Line 86:
::Value types (types defined using ''struct'') support ''encapsulation'', member/instance ''methods'', ''properties'' and can ''implement interfaces''. Javas primitive types doesn't support any of those concepts. In C# the "primitive" types are merely value types and the developer can declare new custom value types. In Java there's a fixed number of primitive types. Developers can not define new primitive types in Java.
Seems to me that there are plenty of significant differences, right? [[User:Useerup|Useerup]] ([[User talk:Useerup|talk]]) 23:38, 21 October 2010 (UTC)
:: value types are also some kind of syntactic sugar, because when you pass a value type in a method which accept only a reference type (a regular instance, as in Java), C# has to do boxing / unboxing under the hood. It's exactly as if you had a special mutable object which you use to hold the primitive value. In fact, I think that it's exactly the way C# works. So when you think that you are creating a new primitive type in C#, in fact, you are creating a new kind of mutable object which contains a value of this primitive type. And custom value types as structs is really is way of holding more than one primitive value in the associated Object. And as it is boxed / unboxed, performacne suffer because of that. Syntactic sugar. [[User:Hervegirod|Hervegirod]] ([[User talk:Hervegirod|talk]]) 22:01, 25 October 2010 (UTC)
<br />