Classes and structures

C# like any other programming language has the concept of data types. You can create variables by specifying the type of that variable. Any data type which you have in C# will be either a class or a structure. For example when you write

int I = 10;

Here int is the data type which you are using. In C# int is a structure. Similarly char, float, double etc are all structures.
When you write

string str = “Hello”;

Here string is a class.

Out of all the data types in C#, including pre defined data types and user defined data types, you will find more than 90% to be of the type class. Rest 10% would be of the type structures or enums.

A helpful trick

If you are not sure whether the data type which you are using is a class or a structure then you can simply take your mouse over that data type and Visual Studio will tell you about it. Look at the screenshot below

Structures in C#
 
Here you see Visual Studio telling you that int is a structure

Classes in C#
 
Here you see Visual Studio telling you that string is a class.
Using this trick you can see if the data type you are using is a class or a structure.

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp