471,325 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

What is Parial class ?

What’s the role of Partial keyword which is bydefault written for a class in 2.0 ?

public partial class Form1 : Form

Jun 27 '08 #1
6 1355
OK; just noticed all your other posts... what is this? homework? interview?

Marc
Jun 27 '08 #2
On May 19, 6:27 am, satyanarayan sahoo wrote:
What’s the role of Partial keyword which is bydefault written for a class in 2.0 ?

public partial class Form1 : Form
It's only included by default for classes which have an associated
designer. As Marc says, your questions do sound somewhat like homework
assignments...

(A search for "partial keyword C#" finds plenty of results...)

Jon
Jun 27 '08 #3
"satyanarayan sahoo" wrote in message
news:20*************************@gmail.com...
What’s the role of Partial keyword which is bydefault written for a class
in 2.0 ?

public partial class Form1 : Form
The "partial" keyword applied to a class allows you to split the class
definition accross two or more source files. This was not possible under the
framework 1.0 (each class had to be contained in a single .cs file). Under
the Framework 2.0 (and later), this was added for the purpose of "cleaning"
the autogenerated classes, so that you could have the autogenerated part
(such as the design for a winform) in a file that you never edit, and then
add your own members on a separate file. It can also be useful in the case
were several developers are working on the same class. You can split the
class into several files, and have each of your developers check out of the
source code control system one of the fragments of the class.

Jun 27 '08 #4
The partial keyword allows the class, struct, or interface to span across multiple files. Typically a class will reside entirely in a single file. However, in situations where multiple developers need access to the same class, or more likely in the situation where a code generator of some type is generating part of a class, then having the class in multiple files can be beneficial.
1.Partial classes can improve code readability and
maintainability by providing a powerful way to extend the
behavior of a class and attach functionality to it.

2.The partial modifier can only appear immediately before
the keywords class, struct, or interface.

3.Nested partial types are allowed in partial-type
definitions.

4.Using partial classes helps to split your class
definition into multiple physical files.

5.Note that the partial keyword applies to classes,
structs, and interfaces, but not enums
Jun 27 '08 #5
Hi Jon and others,

In my idea is Marc right, I am not such a regular in this newsgroup, however
Marc follows exactly the policy from some other dotnet newsgroups.

It make no sense to help a student with his answers. Have a look as Marc
wrote to his others questions where he becomes even lazy in that.

Cor
"Jon Skeet [C# MVP]" <sk***@pobox.comschreef in bericht
news:ca**********************************@x35g2000 hsb.googlegroups.com...
On May 19, 6:27 am, satyanarayan sahoo wrote:
What’s the role of Partial keyword which is bydefault written for a class
in 2.0 ?

public partial class Form1 : Form
It's only included by default for classes which have an associated
designer. As Marc says, your questions do sound somewhat like homework
assignments...

(A search for "partial keyword C#" finds plenty of results...)

Jon

Jun 27 '08 #6
Cor Ligthert[MVP] <no************@planet.nlwrote:
In my idea is Marc right, I am not such a regular in this newsgroup, however
Marc follows exactly the policy from some other dotnet newsgroups.

It make no sense to help a student with his answers. Have a look as Marc
wrote to his others questions where he becomes even lazy in that.
Well, I was:

a) correcting the statement within the question
b) giving the poster information to answer his own question

I agree that doing people's homework for them is a bad idea, but I
really don't think I was doing that.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
54 posts views Thread by Brandon J. Van Every | last post: by
56 posts views Thread by Xah Lee | last post: by
12 posts views Thread by Steven T. Hatton | last post: by
72 posts views Thread by E. Robert Tisdale | last post: by
3 posts views Thread by Steven T. Hatton | last post: by
4 posts views Thread by N.RATNAKAR | last post: by
44 posts views Thread by Steven D'Aprano | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.