C with a Lot More Class: C#
By John Pearson
It's no secret that because Java and HTML have become the default languages of the Internet, Microsoft needed to come up with something comparable. Thus far, Sun has squabbled with Microsoft over Java licensing and attacked Microsoft's Java offerings in court. Now rumor has it that C# (pronounced "C-Sharp") has been conceived as Microsoft's Java-killer. This new language is clearly a descendant of C++, and it closely resembles Java. In fact, it's enough like both that programmers from either camp should feel somewhat at home with it.
A Closer Look
Will C and C++ programmers have a built-in comfort level with C#? Yes, in the same way that Quick Basic programmers recognize features of Visual Basic. The languages are similar, but C# adds many sophisticated features that C and C++ don't have. For example, see the C# version of the traditional "Hello, World!" program in
Example 1.
While the main entry point for a C# program is always a method called Main, the Main method isn't really the "main" oneit's a static method within a class. Like Java, every program is ultimately a class. (Classes can also easily become Web services, as Brian Jepson illustrates in "Applying .Net Web Services.")
The first line of the "Hello, World!" program has a comment that uses the same syntax as C++ (and Java), and the second line indicates that this program uses a namespace called System.<>