Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C#
C# Reference
C# Keywords
 struct
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
C# Language Reference
struct (C# Reference)

Updated: November 2007

A struct type is a value type that is typically used to encapsulate small groups of related variables, such as the coordinates of a rectangle or the characteristics of an item in an inventory. The following example shows a simple struct declaration:

public struct Book
{
    public decimal price;
    public string title;
    public string author;
}

Structs can also contain constructors, constants, fields, methods, properties, indexers, operators, events, and nested types, although if several such members are required, you should consider making your type a class instead.

Structs can implement an interface but they cannot inherit from another struct. For that reason, struct members cannot be declared as protected.

For more information, see Structs (C# Programming Guide).

For more information, see the following sections in the C# Language Specification:

  • 11 Structs

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Recommendation/Suggestion On Refinement To Struct      G1   |   Edit   |  
  1. a base type for structures such as "struct"
  2. more features available to struct when passed as generics, in particular, Parse and TryParse seems available on all structures but is available to the generic parameter instance.

Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker