Describe new features introduced with C# 2.0 ?

 New features C# 2.0 are:
  1. Generics - The .NET Framework class library contains several new generic collection classes in the System.Collections.Generic namespace. These should be used whenever possible in place of classes such as ArrayList in the System.Collections namespace.
  2. Iterators - make it easier to dictate how a foreach loop will iterate over a collection's contents.The yield keyword is used to specify the value, or values, returned. When the yield return statement is reached, the current location is stored. Execution is restarted from this location the next time the iterator is called. You can use more than one yield statement in the same iterator
  3. Partial Classes - Partial type definitions allow a single type, such as a class, to be split into multiple files. The Visual Studio designer uses this feature to separate its generated code from user code.
  4. Nullable Types - Nullable types allow a variable to contain a value that is undefined. Nullable types are useful when working with databases and other data structures that may contain elements that contain no specific values.
  5. Anonymous Methods - It is now possible to pass a block of code as a parameter. Anywhere a delegate is expected, a code block can be used instead: there is no need to define a new method.
  6. Namespace alias qualifier - The namespace alias qualifier (::) provides more control over accessing namespace members. The global :: alias allows access the root namespace that may be hidden by an entity in your code.
  7. Static Classes - Static classes are a safe and convenient way of declaring a class containing static methods that cannot be instantiated. In C# version 1.2 you would have defined the class constructor as private to prevent the class being instantiated.
  8. External Assembly Alias - Reference different versions of the same component contained in the same assembly with this expanded use of the extern keyword.
  9. Property Accessor Accessibility - It is now possible to define different levels of accessibility for the get and set accessors on properties.
  10. Covariance and Contravariance in Delegates -The method passed to a delegate may now have greater flexibility in its return type and parameters.

No comments:

Popular Posts