O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required