What is Parial class ?

  • Thread starter Thread starter satyanarayan sahoo
  • Start date Start date
S

satyanarayan sahoo

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

public partial class Form1 : Form
 
OK; just noticed all your other posts... what is this? homework? interview?

Marc
 
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
 
in message
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.
 
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
 
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]" <[email protected]> schreef in bericht
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
 
Cor Ligthert said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top