O'Reilly logo

Illustrated C# 2008 by Daniel Solis

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

Chapter 12. Structs

What Are Structs?

Structs areprogrammer-defined data types, very similar to classes. They have data members and function members. Althoughsimilar to classes, there are a number of important differences. The most important ones are the following:

  • Classes are reference types and structs are value types.

  • Structs are implicitly sealed, which means that they cannot be derived from.

The syntax for declaring a struct is similar to that of declaring a class.

What Are Structs?

For example, the following code declares a struct named Point. It has two public fields, named X and Y. In Main, three variables of struct type Point are declared, and their values are ...

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