C#    up
  similar languages: C   C++   C-Talk   D   Cilk   Java   Objective-C   Pike   TOM  
  Description: C# (C sharp) is Microsofts answer to Suns Java. C# ties the speed and powerfulness of C++ and the high productivity of Visual Basic together. The only disadvantage of C# is the platform-dependency, because C# will probably only be available for Windows. C# has garbage-collection, but it is also possible to use pointer-arithmetric in special declared blocks and be responsible for the memory-removal. In C# all datatypes are objects, that is you can e.g. call a method on an integer. C# has build-in COM-functionality, so there are getter/setter-methods (properties) and events. Every C#-object is automatically a COM-object and because of that any other COM-object created in any language can be used. Altogether a very interesting language (especially for Windows-developer), wherby the change from C++ will not be very hard. Very interesting is the meta-documentation. To every element (class, method...) a documentation can be added, whereby the type of the documentation can be defined by C#-classes. You can access the documentation during runtime.


 Hello World   Michael Neumann
// Hello World in C#

using System;
class HelloWorld {
   static void Main() {
      Console.WriteLine("Hello World");
   }
}
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
using System;
class Squares1 {
   static void Main() {
      for (int i=1; i<=10; i++) {
         Console.WriteLine("{0} ", i*i);
      }
   }
}
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
using System;
class Squares2 {
   static void Main() {
      string res = "";
      int[] arr  = {1,2,3,4,5,6,7,8,9,10}; // short form for "new int[] = {1,2,...}"
      
      for (int i=0; i<arr.Length; i++) {
         res += (arr[i]*arr[i]).ToString() + " ";
      }
      Console.WriteLine("{0}", res);
   }
}
Outputs the squares from 1 to 10.