CA New Programming Language

I l @ ve RuBoard

C#”A New Programming Language

C# is possibly the biggest source of the controversy that has dogged the .NET framework since its unveiling to the public in early 2000. Previously named Cool and shrouded in mystery, disinformation, and speculation, C# is actually a very good, totally object-oriented, simple language.

It is obvious that the designers of C# went to a lot of effort to create a language that was palatable to C++ programmers. It is easy to adapt to and has many of the same language constructs as C++. A few things are very conspicuous by their absence, however.

Multiple inheritance does not figure in the C# scheme. A C# class may declare that it implements one or more interfaces, but multiple inheritance of base classes is not possible. To some programmers, especially ATL lovers, this might be a shortcoming.

The C# system does not allow for any sort of templates, either. There are ways around that problem, though, which we will show you later in this book. Most of the C# controversy has been from the reactions of people who have dismissed it as a blatant effort to rip off Java. We believe that C# and Java are horses for different courses and can coexist happily. C# and the whole .NET framework are better suited to a mixture of client-side and server-side work, whereas Java has definite shortcomings for the client.

It was mentioned that C# is "totally object-oriented." C++ came from C. It was at first a tricky add-on to C, then a true attempt at object orientation. At best, C++ is a compromise that still retains some of the characteristics of a non“object-oriented language. It has standalone functions and global variables. C# on the other hand, does not have a non“object-oriented bone in its body. All the variable types, even simple value types, can be treated as objects. All functionality must be contained within a class. Global variables are not allowed. (Don't despair, though. You can have classes with static functions or variables. These can be used in lieu of true global variables if you must have them.)

Just to give you a snippet of real code, here is the famous, infamous, beloved, hated, hello world example, written in C#.

 using System; class helloworld {     public static int Main()     {     Console.WriteLine("Hello World");     return 0;     } } 

See, you understood that just fine!

I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net