.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

What Do We Use Classes For?

Posted By:Shashi Ray       Posted Date: February 22, 2009    Points: 15    Category: C#    URL: http://www.dotnetspark.com  

What Do We Use Classes For?


All C# programs are composed of classes. The Windows forms we have just seen are classes, derived from the basic Form class and all the other programs we will be writing are made up exclusively of classes. C# does not have the concept of global data modules or shared data that is not part of classes.


Simply put, a class is a set of public and private methods and private data grouped inside named logical units. Usually, we write each class in a separate file, although this is not a hard and fast rule. We have already seen that these Windows forms are classes, and we will see how we can

create other useful classes in this chapter.


When you create a class, it is not a single entity, but a master you can create copies or instances of, using the new keyword. When we create these instances, we pass some initializing data into the class using its constructor. A constructor is a method that has the same name as the class

name, has no return type and can have zero or more parameters that get passed into each instance of the class. We refer to each of these instances as objects.


Shashi Ray

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend