How to create class in c#.net?

This item was filled under [ Interview Questions ]

Class having the structure like c++ and java in c#.net and microsoft adding some functionality for class. the structure of class is below.

class class_name

{

//here we can declare members.

public | private | protected | protected internal member_name;

class_name()// this called constructor.

{

//here we can assign values for members.

member_name=values;

}

//here we can declare member function.

public | private | protected | protected internal function_name(arguments)

{

//here we can write the functionality of this function.

}

}

the above examples having public | private | protected | protected internal these are called access modifiers.

constraints of class

1. Constructor name and class name should be same.

2. Constructor should not have a return type.

3.By default protection level is private for constructor.

4.Class name should starts with alphabets.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
Tagged with: [ , ]
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Comment

You must be logged in to post a comment.