Structs

Let's learn about structs.

What is a struct?

A struct is similar to a class and is useful for lightweight objects, such as a point, rectangle, or color. Lightweight objects can also be created with classes, but it’s often more memory efficient to use a struct. Unlike classes, structs are value types, not reference types.

Syntax

public struct TheLocation {
  // Empty struct
}

Get hands-on with 1200+ tech skills courses.