Discussion Points

Mark the following features of value types and reference types and discuss the reasons for your answers in the class.

• Contain the actual data.

• Examples include structure, integer and float.

• Variables are independent of each other.

• Variables can refer to the same data.

• Contain the memory address of the actual data.

• Examples include classes and interfaces.

Lesson 2: Working with Special System Types

You can develop robust .NET Framework applications easily and rapidly by using base system types. The .NET Framework includes some special system types that take the .NET Framework applications further with better type safety, fewer bugs, and better customizability. These special system types are generics, Nullable types, exception classes, and attributes.

Generics is a new concept to the .NET Framework 2.0. In earlier versions of the .NET Framework, objects are added to a collection after implicit casting to the System.Object type. This results in compromising type safety. In the .NET Framework 2.0, you can use the predefined collections and interfaces that generics provide to create collection objects or define custom types that are type-safe.

The .NET Framework 2.0 provides a special system type called Nullable. You can use this special system type to declare value types that can store null values.

The .NET Framework 2.0 also provides other special system types such as exception classes and attributes. You can use exception classes to handle error conditions during run time. You can use attributes to convey information to the run time about the behavior of programmatic elements, such as classes, enumerators, and assemblies.

This lesson introduces you to special system types and describes how to implement special system types in the .NET Framework.

Was this article helpful?

0 0

Post a comment