Declaring enumerations:
Enum Season{spring,summer,fall,winter}
If you do not specify a constant integer type for enumerating an enumerated literal constant, the compiler automatically assigns a value to him that is older than the previous enumerated literal constant.
Enum Season{spring=1,summer,fall,autumn=fall,winter}
Select the basic type of enumeration:
Enum Season:short{spring,summer,fall,winter}
Declaration structure:
struct TIME
{
private int hours,minutes,seconds;
Public time (int hh,int mm,int SS)
{
hours=hh%24;
minutes=mm%60;
seconds=ss%60;
}
public int hours ()
{
return hours;
}
}
Understand the differences between structs and classes:
You cannot declare a default constructor for a struct, the compiler always declares a constructor for us, the default constructor always initializes the field to Null,0,false, and if you write a non-default constructor, all fields are initialized;
The class can be declared again when an instance field is initialized, but is not allowed in the structure;
To copy a struct variable:
If the struct variable on the right is fully initialized, it can be copied directly to the left;
C # Basic Grammar review-use enumerations and structs to create value types