Chapter 43: C, Visual Basic, and CCLI


Overview

C# is the programming language designed for .NET. More than 50 languages exist for writing .NET applications, for example, Eiffel, Smalltalk, COBOL, Haskell, Pizza, Pascal, Delphi, Oberon, Prolog, Ruby, and many more. Microsoft alone delivers the languages C#, Visual Basic, C++/CLI, J#, and JScript.NET.

Every language has advantages and disadvantages; some things can be done easily with one language but are complicated with another one. The classes from the .NET Framework are always the same, but the syntax of the language abstracts various features from the Framework. For example, the C# using statement makes it easy to use the objects implementing the IDisposable interface. Other languages need more code for the same functionality.

The most commonly used .NET languages from Microsoft are C# and Visual Basic. C# was newly designed for .NET with ideas from C++, Java, Pascal, and other languages. Visual Basic has its roots in Visual Basic 6 and was extended with object-oriented features for .NET.

C++/CLI is an extension to C++ that is an ECMA standard (ECMA 372). The big advantage of C++/CLI is the ability to mix native code with managed code. You can extend existing native C++ applications and add .NET functionality, and you can add .NET classes to native libraries so that they can be used from other .NET languages such as C#. It is also possible to write completely managed applications with C++/CLI.

This chapter shows you how to convert .NET applications from one language to another. If you see sample code with Visual Basic or C++/CLI, you can easily map this to C#, and the other way around.

The topics covered in this chapter are:

  • Namespaces

  • Defining types

  • Methods

  • Arrays

  • Control statements

  • Loops

  • Exception handling

  • Inheritance

  • Resource management

  • Delegates

  • Events

  • Generics

  • C++/CLI mixing native and managed code

Tip 

For this chapter, it is expected that you know C# and have read the first few chapters of this book. It is not necessary that you know Visual Basic and C++/CLI.




Professional C# 2005 with .NET 3.0
Professional C# 2005 with .NET 3.0
ISBN: 470124725
EAN: N/A
Year: 2007
Pages: 427

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