Please enable Javascript to correctly display the contents on Dot Net Tricks!

Introduction to C Sharp

Posted By : Shailendra Chauhan, 22 Aug 2011
Updated On : 14 Jul 2012
Total Views : 85,831   
 

C# is developed by microsoft and comes after C, C++, Java. It inherits the properties of C, C++, Java, VB. We can say C# is smart and intelligent sister of Java because it do work smartly in comprasion to Java. The basic concept of C# language are same as C, C++ to whom you have learnt in C, C++ tutorials. The advance concept of C# language are as :

Object

Object is representative of the class and is responsible for memory allocation of its data members and member functions.An object is a real world entity having attributes (data type) and behaviors (functions).

Class

Class is a data structure that contains data members (constants files, events), member function methods, properties, constructor, destructor, indexers and nested type.Basically :

  1. It is a user defined data type.

  2. It is a reference type.

  3. Infact class is a tag or template for object.

Drawback of Class

Class does not allocate memory to its data members & member function itself.Basically memory is allocated through object of a class.Class can’t explore itself means it can not access its members itself, to access members of a class we use object of that class.

Example :

 // Namespace Declaration
using System; 
// helper class 
class ClassA 
{ 
string myString; 
// Constructor
public ClassA(string str) 
{ 
myString = str;
 } 
 // Instance Method 
 public void Show() 
 { 
 Console.WriteLine("{0}", myString);
 } 
 // Destructor 
 ~ClassA()
 { 
 // Some resource cleanup routines
 } 
} 
// Program start class 
class ClassProgram 
{ 
// Main begins program execution
public static void Main() 
{ 
// Instance of ClassA 
ClassA objA = new ClassA("Welcome to the world of C# language !!");
// Call ClassA method 
 objA.Show();
 } 
} 
 
Recommended for you
 
About the Author
Shailendra Chauhan

Shailendra Chauhan is an Entrepreneur, Author, Architect, and Corporate Trainer. He has rewarded as Microsoft MVP for his exceptional contributions in Microsoft Visual Studio and Development Technologies.

With more than 7 years in hand experience Shailendra Chauhan is a polymath in the domains of Microsoft .NET technologies and an array of other technologies including JavaScript, AngularJS, Node.js, Ionic and NoSQL Databases to name but a few.

He is the author of some of most popular e-books which encompass technical Interview on Node.js Interview Questions and Answers , ASP.NET MVC Interview Questions and Answers , AngularJS Interview Questions and Answers and LINQ Interview Questions and Answers. Furthermore he is a technical reviewer for book on ASP.NET MVC 4 Mobile App Development. Know more...
 
Free Interview Books
 
4 AUG
NodeJS Development (online)

Thursday 06:00 AM-7:30 AM IST

More Details
1 AUG
AngularJS Development (online)

Mon-Fri 09:00 PM-10:30 PM IST

More Details
29 JUL
ASP.NET MVC with AngularJS Development (online)

Mon-Fri (07:30 AM-09:00 AM IST)

More Details
24 JUL
AngularJS Development (offline)

Sat,Sun     (08:00 AM-09:30 AM)

24 JUL
ASP.NET MVC with AngularJS Development (offline)

Sat, Sun     (09:30 AM-11:00 AM)

28 MAY
ASP.NET MVC with AngularJS Development (offline)

Sat, Sun     (05:00 PM-07:00 PM IST)

30 APR
NodeJS Development (offline)

Sat, Sun     (11:00 AM-12:30 PM IST)

BROWSE BY CATEGORY
 
SUBSCRIBE TO LATEST NEWS
 
LIKE US ON FACEBOOK
 
+