The upcoming release of the .NET 2.0 framework brings many new enhancements to the CLR and the C# and VB.NET languages, and with the availability of Beta2, it seems like an appropriate time to dive into the .NET 2.0 framework and see what’s cooking. Since .NET is a platform that supports multiple languages my approach with each new release has been to review what the CLR has to offer first, since it is the foundation for all languages, and then review what is common for the languages I use the most, which are C# and VB.NET. Last, I review each language on its own to see how each enhancement can solve the particular shortfalls of the previous version and how the new enhancements can improve the clarity and efficiency of my code. Now with this solid understanding behind me I can make better decisions as to which language or languages to use on my next project.

CLR Enhancements
The new enhancement that stands out the most in terms of enterprise computing is the 64-bit version of the .NET framework. This version of the framework allows you to take full advantage of the underlying 64-bit hardware platform without having to deal with the differences between 32-bit and 64-bit hardware platforms. What this means is if you created a 32-bit application that doesn’t rely on floating-point numbers or native code you can simply compile your code using the 64-bit compiler, for your language of choice, and begin running your application on a Windows 2003 SP1 or Windows XP 64-bit operating system with no modifications.
   
Generics are another enhancement that I will keep under the CLR umbrella due to the CLS compliance to them. Generics provide developers with a way to create type-safe data structures consisting of classes and interfaces that are data-type agnostic. This means that when you declare your type-safe data structure you put a placeholder for the agnostic type and during instance creation you specify the actual type used. An example of creating a custom generic type can be seen in Listing 1. One of the strengths you can see right away with Generics is their use in collections where you were previously forced to use the System.Object data type no matter what type you passed in. This of course incurred boxing for value types which let to a performance hit. To help us out Microsoft has created the System.Collections.Generic namespace. It provides an assortment of commonly used generic collections that you can use so you don’t have to create type-safe collections by hand unless you want to.
   
Friend assemblies are another new enhancement that enable developers to expose C# internal and VB.NET friend decorated types and methods to multiple assemblies. In the past this was accomplished by either making the type public, which exposed the type to all assemblies, or decorating each type or method with the StrongNameIdentity- Permission attribute, which was time consuming and error prone. With friend assemblies, adding the [assembly:InternalsVisibleTo(“AssemB, PublicKeyToken= 32ab9ba32e0a51a1” )] attribute to the assembly allows all friend-specified types or methods to be visible in the named assembly.

Read More | Symbian Developers Journal


 
Comments are closed.