C# Versus Java
By Marc Eaddy, February 01, 2001
Microsoft describes C# ("C sharp") as a "simple, modern, object-oriented, and type-safe programming language derived from C and C++." That statement would apply equally well to Java. In fact, after comparing the two languages, it's obvious that prerelease descriptions of C# resemble Java more than C++. As Example 1 illustrates, the language features and syntax are similar. Example 1(a) is the canonical "Hello World" program in Java, while Example 1(b) is the program in C#.
Feb01: C# Versus Java
<b>(a)</b>
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
<b>(b)</b>
class HelloWorld {
public static void Main(string[] args) {
System.Console.WriteLine("Hello, World!");
}
}
Example 1: Hello World. (a) in Java; (b) in C#.