This chapter discussed structs, how they compare with classes, and how they are defined and used.

The following important points were covered in this chapter.

Structs are similar to classes in many ways but also have important differences.

Structs are lightweight alternatives to classes. They are advantageous for representing one or a few related data items.

Structs do not support inheritance, but all structs are implicitly derived from System.Object.

The execution engine implicitly transforms a value type into a reference type when needed. This is called boxing. The reverse process of transforming this reference type back to a value type is called unboxing and requires an explicit cast.

All the data members of a struct must be initialized before any functions of this struct can be called.


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: