Author Topic: What are you guys coding?  (Read 11966 times)

0 Members and 1 Guest are viewing this topic.

Offline Ender

  • x86
  • Hero Member
  • *****
  • Posts: 2398
    • View Profile
Re: What are you guys coding?
« Reply #45 on: February 21, 2007, 10:16:54 am »
1.) Primitives can be used as types (you don't need to declare a class to use their methods).  For instance, in Java you would have to:
Code: [Select]
int val = 50;
Integer inte = new Integer(val);
whereas in C# you can do this on the primitive directly:
Code: [Select]
int val = 50;
// or if you're really adventurous
I believe as of Java 1.5, Java supported automatic class promotion of a primitive whenever an object method was called (to make it syntactically equivalent to C#).  However, the Java compiler still emits the object silently, making the bytecode equivalent of the former.  C# does not require object instantiation.


7.) foreach.  The foreach operator works on any object that implements the IEnumerable interface.

Java has foreach too, since 1.5, which, IIRC, works on any Collection, although there may be a more generic type that it works for.