Geeks With Blogs
Sharvan Dhaka blog
Partial class is a new functionality that is included in Visual Studio .Net 2005 and is supported in ASP.Net 2.0. This new functionality helps you to split a single class into multiple partial classes. These partial classes can be in different individual files.

In the earlier versions of Visual Studio .Net 2005, while you create an ASP.Net application, you might have seen that a single class has to be in a single file. You will be beginning a class and ending that class in the same file. It was not possible to split a single class across multiple files. This new feature, partial class, allows you to allot different developers to develop the code for different functionalities that are available in a single class. These functionalities can be developed in partial classes and then compiled to form the required assembly.

In the previous versions of the Visual Studio .Net IDE, when you create a new ASP.Net webform, the name of the web form is used as a class in the code-behind file. Apart from that, you would have seen lots of code generated by Visual Studio .Net itself. In the latest version of the Visual Studio .Net IDE, the codes that are generated by Visual Studio .Net are in a separate file as a partial class. Hence a user who creates a new webform would see a partial class for that page, when the user uses the code-behind file. This way the code that is seen in the code-behind file is minimal for a particular webform.

The compilers for VB.Net or C# look for the partial classes and integrate them while compiling, to form the intermediate language. This intermediate language is the same when compared to the intermediate language that is generated, if all the partial classes are combined to form a single class in a single file. There is no modification done in the CLR for the implementation of partial classes.

The CLR finds no difference in the intermediate language, even if the IL is produced by having a single class in a single class file, where all the methods of the interface are implemented in a single class in a single class file. Since we are dealing with different files for a single class, even if you missed out implementing one method of an interface, the intellisense of Visual Studio .Net 2005 will point it out to you, thus enabling you to implement the missed out method of the interface. This is one among the advantage of using a Visual Studio .Net 2005 IDE for ASP.Net 2.0 applications.

This type of splitting the class file is particularly useful if a single class runs to thousands of lines of code with different functionalities across different methods. Productivity of the project team is increased since a single class file is split across the team members and implemented as partial classes. Posted on Sunday, October 15, 2006 4:14 PM Asp.net 2.0 New , Asp.net , c# | Back to top


Comments on this post: Partial Classes in ASP.NET

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Sharvan Dhaka | Powered by: GeeksWithBlogs.net