Home > Article > Backend Development > What are user-defined data types in C#?
In C#, user-defined data types are structures and enumerations.
In C#, a structure is a value type data type. It helps you make a single variable hold related data of various data types. Use the struct keyword to create structures.
C# structures have the following characteristics:
An enumeration is an enumeration used to store a set of named constants, such as year, product, month, season, etc.
The default value of enumeration constants starts from 0 and increases. It has a fixed set of constants and can be easily traversed.
Let's look at an example.
We set up the following enumeration:
public enum Vehicle { Car, Bus, Truck }
The above is the detailed content of What are user-defined data types in C#?. For more information, please follow other related articles on the PHP Chinese website!