I.T. Discussion Community!
-Collapse +Expand
To/From Code
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesC#  Print This     

Partial Class

A partial class, or partial type, is a class that can be split into two or more source code files and/or two or more locations within the same source file. Each partial class is known as a class part or just a part. Logically, partial classes do not make any difference to the compiler. The compiler puts the class together at compile time and treats the final class or type as a single entity exactly the same as if all the source code was in a single location.

Languages Focus

For languages that have implemented partial classes, you need to know usage details and restrictions. Can you split a class into two or more files? Can you split a class within a source code file into two or more locations? What are the details of inheritance? Does it apply to interfaces as well?

C#:  "Partial Classes" partial

C# uses the keyword partial to specify a partial class. All parts must be in the same namespace.

Syntax Example:
class partial Cyborg: System.Object

Cross Reference Examples:

Access VBA:  "Partial Classes" Not Supported
ASP Classic:  "Partial Classes" Not Supported
C++:  "Partial Classes" Not Supported

In C++, you can split the implementation of a class among two or more source files. However, you must declare the member in the class declaration.

C++/CLI:  "Partial Classes" Not Supported

C++/CLI does not yet support partial classes. My assumption is that it will soon because it is a .Net language´┐Żbut only time will tell.

Corel Paradox:  "Partial Classes" Not Supported
Delphi:  "Partial Classes" Not Supported

As of Delphi 2009, partial classes are not supported. The main reason given in the thread below was that the Delphi compiler is a single pass compiler. Here is a link to a discussion thread on the subject:

Delphi Prism:  "Partial Classes" partial

Prism supports both partial classes and partial methods using the keyword partial. A partial method is an empty method defined in a partial class.

Syntax Example:
//Organize a large class in multiple files.
T800 = partial class(Cyborg, IHuman);
T800 = partial class(ITalk);
//Partial methods too:´┐Ż
T800 = public partial class
method Walk; partial; empty;
method Run; partial; empty;
Java:  "Partial Classes" Not Supported
VB Classic:  "Partial Classes" Not Supported
VB.Net:  "Partial Classes" Partial

VB.Net supports both partial classes and partial methods.

Syntax Example:
Partial Public Class Cyborg
Inherits System.Object
End Class

   Contact Us!
PrestwoodBoards.com was developed and is maintainted by me. Do you have a question or suggestion? Do you see a problem? Contact me now. My goal is to build an ad-free and spam-free source of I.T. information with many contributers (ok to promote your website/company in your bio). Yes, my company Prestwood IT Solutions is mentioned in my bio which shows with every post, but you can contribute and promote your pet project too!

2,813 People Online Now!!  
Sign In to see who's online now!  Not a member? Join now. It's free!
Show more stats...

©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech