Summary


In this chapter, you’ve learned how to map the syntax from C# to Visual Basic and C++/CLI. C++/CLI defines extensions to C++ for writing .NET applications and draws on C# for the syntax extensions. Although C# and C++/CLI have the same roots, there are many important differences. Visual Basic does not use curly brackets, but is chattier instead.

With the syntax mapping, you’ve seen how to map the C# syntax to C++/CLI and Visual Basic; how the other two languages look, with defining types, methods, properties; what keywords are used for OO features; how resource management is done; and how delegates, events and generics are implemented with the three languages.

While it is possible to map most of the syntax, the languages are still different in their functionality. Some C# syntax features were not covered in this chapter. C# defines the yield statement, which makes it easy to create enumerators. This statement is not available with C++/CLI and Visual Basic; with these languages an enumerator must be implemented manually. Also, C# defines a special syntax for nullable types, whereas with the other languages you have to use the generic struct Nullable<T> instead.

C# allows for unsafe code blocks where you can use pointers and pointer arithmetic. This feature can be extremely helpful for invoking methods from native libraries. Visual Basic does not have this possibility; this is a real advantage of C#. C++/CLI does not need the unsafe keyword to define unsafe code blocks. It’s very natural with C++/CLI to mix native and managed code.




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