What is Partial class

Questions by hksjadon

Editorial / Best Answer

bb.geetha  

  • Member Since May-2008 | Jun 12th, 2008


A Partial class is a class that can be split into two or more classes. This means that a class can be physically separated into other parts of the class within the same namespace. All the parts must use the partial keyword. All the other classes should also have the same access modifier. At the compile time, all the partial classes will be treated as a single class. Let us list some advantages of having partial classes.

Showing Answers 1 - 25 of 25 Answers

Sohaib Ahmad

  • Sep 28th, 2006
 

The class which can be split into mulitple files in partial class.

  Was this answer useful?  Yes

sriraja

  • Nov 19th, 2006
 

 A class having splited into different files ex.. program.cs(application.run),form related files,class related files

  Was this answer useful?  Yes

don22222000

  • Jul 13th, 2007
 

In ASP.Net, Partial Class is the common class that links the Presentation layer to the Code behind page. Its basically an inheritance class.

  Was this answer useful?  Yes

bornToLose

  • Sep 22nd, 2007
 

It is possible to split class, struct and interface into multiple source file. Each file contain section of class definition and combined all file at time of compilation.  It is used when:
1. Program is very large
2. Automatic generate source code

  Was this answer useful?  Yes

bb.geetha

  • Jun 12th, 2008
 

A Partial class is a class that can be split into two or more classes. This means that a class can be physically separated into other parts of the class within the same namespace. All the parts must use the partial keyword. All the other classes should also have the same access modifier. At the compile time, all the partial classes will be treated as a single class. Let us list some advantages of having partial classes.

The class having partial keyword and same name. One class can split into more than two parts having same name and partial keyword. In the time of object creation all partial class group together to make the single object.

The main aim for the partial class is that giving more liberty to the developer, different developer can work on same class without interpreting to each other.

  Was this answer useful?  Yes

lata negi

  • Nov 4th, 2011
 

Partial class is a new feature added to .NET Framework 2.0. .NET 1.0 or 1.1, does not support for partial classes.
It is possible to split the definition of a class or a struct, or an interface over two or more source files. Each source file contains a section of the class definition, and all parts are combined when the application is compiled.

When working on large projects, spreading a class over separate files allows multiple programmers to work on it simultaneously.

Points to be noted while writing code for partial classes:-

All the partial definitions must proceeded with the key word "Partial".

All the partial types meant to be the part of same type must be defined within a same assembly and module.
Method signatures (return type, name of the method, and parameters) must be unique for the aggregated typed (which was defined partially).

The partial types must have the same accessibility.
If any part is sealed, the entire class is sealed.
If any part is abstract, the entire class is abstract.
Inheritance at any partial type applies to the entire class.

Two or more different class having the same name and datatype but physically different from each other. At compile time all the partial class are complied in to one single entity(class) and all the methods, properties defined in different classes are available by creating the object of that class.

It is useful when multiple developers worked on the same class at the same time.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions