A struct-declaration is a type-declaration (§16.5) that declares a new
struct:
struct-declaration:
attributesopt struct-modifiersopt struct identifier struct-interfacesopt
struct-body ;opt
A struct-declaration consists of an optional set of attributes (§24),
followed by an optional set of structmodifiers
(§18.1.1), followed by the keyword struct and an identifier that names the
struct, followed by an
optional struct-interfaces specification (§18.1.2), followed by a
struct-body (§18.1.3), optionally followed
by a semicolon.
18.1.1 Struct modifiers
A struct-declaration may optionally include a sequence of struct modifiers:
struct-modifiers:
struct-modifier
struct-modifiers struct-modifier
struct-modifier:
new
public
protected
internal
private
It is a compile-time error for the same modifier to appear multiple times
in a struct declaration.
The modifiers of a struct declaration have the same meaning as those of a
class declaration (§17.1.1).
18.1.2 Struct interfaces
A struct declaration may include a struct-interfaces specification, in
which case the struct is said to
implement the given interface types.
struct-interfaces:
: interface-type-list
C# LANGUAGE SPECIFICATION
268
Interface implementations are discussed further in §20.4.
18.1.3 Struct body
The struct-body of a struct defines the members of the struct.
struct-body:
{ struct-member-declarationsopt }
struct:
struct-declaration:
attributesopt struct-modifiersopt struct identifier struct-interfacesopt
struct-body ;opt
A struct-declaration consists of an optional set of attributes (§24),
followed by an optional set of structmodifiers
(§18.1.1), followed by the keyword struct and an identifier that names the
struct, followed by an
optional struct-interfaces specification (§18.1.2), followed by a
struct-body (§18.1.3), optionally followed
by a semicolon.
18.1.1 Struct modifiers
A struct-declaration may optionally include a sequence of struct modifiers:
struct-modifiers:
struct-modifier
struct-modifiers struct-modifier
struct-modifier:
new
public
protected
internal
private
It is a compile-time error for the same modifier to appear multiple times
in a struct declaration.
The modifiers of a struct declaration have the same meaning as those of a
class declaration (§17.1.1).
18.1.2 Struct interfaces
A struct declaration may include a struct-interfaces specification, in
which case the struct is said to
implement the given interface types.
struct-interfaces:
: interface-type-list
C# LANGUAGE SPECIFICATION
268
Interface implementations are discussed further in §20.4.
18.1.3 Struct body
The struct-body of a struct defines the members of the struct.
struct-body:
{ struct-member-declarationsopt }