Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Structs in C#

A struct (short for “structure”) is very similar to a class and it can contain fields, properties, and methods.
However, structs are value types and are created on the stack.

Note:
You cannot inherit from a struct.
A struct can implement an interface.
structs have limited constructor and destructor semantics.

Why Structs ?
Typically, structs are used to aggregate a relatively small amount of logically related fields.

Structures are declared in the same way as classes.

This example shows what might be the start of a struct for imaginary numbers:
  1. struct ImaginaryNumber{
  2. double real;
  3. public double Real{
  4. get { return real; }
  5. set { real = value; }
  6. }
  7. double i;
  8. public double I{
  9. get { return i; }
  10. set { i = value; }
  11. }
  12. }


..