Skip to Content
Microsoft® Visual C#® .NET 2003 Kick Start
book

Microsoft® Visual C#® .NET 2003 Kick Start

by Steven Holzner
June 2003
Intermediate to advanced
624 pages
12h 41m
English
Sams
Content preview from Microsoft® Visual C#® .NET 2003 Kick Start

Creating Structs

C# also supports structs, which you create with the struct keyword. Structs in C# are like lightweight versions of classes. They're not reference types; they're value types, so when you pass them to methods, they're passed by value. They're like classes in many ways—they support constructors, for example (but not inheritance). They take up fewer resources in memory, so when you've got a small, frequently used class, give some thought to using a struct instead. Here's how you declare a struct:

[attributes] [modifiers] struct identifier [:interfaces] body [;]

Here are the parts of this statement:

  • attributes (Optional)— Hold additional declarative information, as we'll see in Chapter 14.

  • modifiers (Optional)— The allowed modifiers ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® .NET Kick Start

Microsoft® .NET Kick Start

Hitesh Seth

Publisher Resources

ISBN: 0672325470Purchase book