Categorized | C# FAQ

Best .net Training : Types of classes in c#

There are Partial,abstract,static,sealed and instance classes in c#.

Partial Class: Partial class is useful when the class functionality is too big (i.e when number of lines of code in the class is too big) and when a developer want to share some of the functionalities with other developers this is useful.

Sealed Class : when the class is functionality is complete and you don’t want to allow any other class to extend your class,then you need to declare your class as sealed. No other Class can extend or use your sealed class as base class.

Abstract Class: When the developer/programmer don’t know the functionality of the class fully and , you want to leave the implementation to the derived classes , then use the Abstract class. In the abstract class you can have 0 or more abstract methods,properties and along with implemented methods. You cannot create an instance to the Abstract Class.And also if you have family of related classes and all those classes having some common functionality try pushing then into a common base class. this way you will get code re-usability and can get easy maintainability.

Static Class: when any class is most frequently used or if any class is qualified as helper class( helper class is one which will be repeatedly used by all other classes) then try using Static Class. Advantage with static class is “Object instantiation overhead is reduced”.And this class always have single memory location where in every other class will hit the same memory location. If class A changed some data in static class , Changed data is available to every other subsequent classes who access the static class.

Note : In the next post you can see the best coding guidelines. Articles written for Palle Technologies. For more details on any training/s login to http://www.techpalle.com . Palle technologies is offering Placement guaranteed training in .net.

EasyFreeAds Blog News Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google Yahoo Buzz StumbleUpon

4 Responses to “Best .net Training : Types of classes in c#”

  1. subhashini says:

    plz clarify me that whether partial class must be implemented in same namespace or in someother namespace

  2. Should be in the same assembly and module also.

  3. Dharmendra says:

    what is differ from assembly,machine and byte code??

  4. ravi says:

    give me simple example for partial class

Trackbacks/Pingbacks


Leave a Reply