Posts

Showing posts from June, 2018

Structures in dotnet and Struct v/s class in dotnet (using C#.net)

CONTENTS C# Structure Structure v/s Class Structure It is also a user-defined type like a class or interface. A C# structure is as same as a class because in C# a structure can contain each and every member what a class can contain like variables method constructors etc. If you need a small data structure that can hold a data that you won't modify later, structs are the best. In C#, a structure is a value type. It helps you to make a single variable to hold related data of various data types. The struct keyword is used for creating a structure. Structures are used to represent a record. Suppose you want to keep track of your books in a library. You might want to track the following attributes about each book:  The Title, Author, Subject, and Book ID Defining a Structure To define a structure, you must use the struct keyword. The struct keyword defines a new data type, with more than one member for your program. For example, here is the way you can declare the Book s