0% found this document useful (0 votes)
26 views6 pages

Partial Class in C#

Uploaded by

Madhuri Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

Partial Class in C#

Uploaded by

Madhuri Patel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PARTIAL CLASS IN C-

SHARP
PROGRAMMING
PRESENTER: MOHAMMAD ADIL
PARTIAL CLASS
• A partial class is a special feature of C#.
• It provides a special ability to implement the functionality of a
single class into multiple files and all these files are combined into
a single class file when the application is compiled.
• A partial class is created by using a partial keyword.
• The partial keyword can also be used to split a struct or an
interface over two or more files.
• We use partial class when code of a class contains so many lines to
manage.
ADVANTAGES OF PARTIAL
CLASS
• Multiple developers can work simultaneously with a single class in
separate files.
• When working on large projects, spreading a class over separate
files allows programmers to work on it simultaneously.
• Visual Studio uses partial classes to separate, automatically
generated system code from the developer’s code. For Example
when you add a webform, two .CS files are generated.
• 1. WebForm1.aspx.cs – Contains the developer code.
• 2. WebForm1.aspx.designer.cs – Contains the system generated
code. For example, declarations for the controls that you drag and
drop on the webform
RULES FOR PARTIAL
CLASS IN C-SHARP
PROGRAMMING
PRESENTER: MOHAMMAD ADIL
RULES FOR PARTIAL CLASS
• All the parts spread across different files, must use the partial
keyword.
• All the partial class definitions must be in the same assembly and
namespace.
• All the parts must have the same accessibility like public or private,
etc.
• If any part is declared abstract then the whole class is declared of
the abstract type.
• If any part is declared sealed then the whole class is declared of
the sealed type.
RULES FOR PARTIAL CLASS
• If any of the parts inherit a class, then the entire type inherits the
class.
• C# does not support multiple class inheritance. Different parts of
the partial class, must not specify different base classes.
• Different parts of the partial class can specify different base
interfaces.
• Any member that are declared in a partial definition are available
to all of the other parts of the partial class.

You might also like