Structures are used to organize data into groups and use them as building blocks for larger programs. Structures also make it easier for developers to reuse code when they need to work with the same pieces of information more than once.
The following example demonstrates how a structure is created using the C# language:
- struct Student { string name; int grade; DateTime birthDate; }
- Student student1 = new Student { "John Smith", 90, DateTime.Now };
- Student student2 = new Student { "Mary Smith", 89, DateTime.Now };
- student1.grade = 90; // Equals
Share a personalized message with your friends.