Variables

Structures in C#

To define a type/structure to store several data items and variables.


Syntax
struct structureName { 
   //member declarations 
};

Notes

Structures can be passed as function arguments (using the struct data type).

To define a specific structure declaration, use the member access operator (.).

Structures can be pointed to, similarly to pointing to variables. To access a member of the structure using pointers, the -> operator must be used.

Structure must be declared as an instance to be accessed. (struct Car car1;).


Example
struct Car { 
   string make; 
   string model; 
   int year;
}; 

Add to Slack

< Type Conversion   |   If Statement >

© 2018 SyntaxDB. All Rights Reserved.