By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,557 Members | 1,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,557 IT Pros & Developers. It's quick & easy.

How to separete a class in more than one source file

P: n/a
Is it possible to divide a class in many .cs files ? For example one source file for each method ?

Thanks.

Nov 22 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
[Please fix your newsreader to wrap lines properly.]

=?Utf-8?B?SnVhcmV6?= <an*******@discussions.microsoft.com> wrote:
Is it possible to divide a class in many .cs files ?
For example one source file for each method ?


Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2

P: n/a
[Please fix your newsreader to wrap lines properly.]

=?Utf-8?B?SnVhcmV6?= <an*******@discussions.microsoft.com> wrote:
Is it possible to divide a class in many .cs files ?
For example one source file for each method ?


Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #3

P: n/a
Juarez <an*******@discussions.microsoft.com> writes:
Is it possible to divide a class in many .cs files ? For example one
source file for each method ?


Now you can't, but when with the Whidbey release of the framework
we'll have partial types you'll be able to do that.

Bye

--
Lawrence "Rhymes" Oluyede
http://loluyede.blogspot.com
Nov 22 '05 #4

P: n/a
Juarez <an*******@discussions.microsoft.com> writes:
Is it possible to divide a class in many .cs files ? For example one
source file for each method ?


Now you can't, but when with the Whidbey release of the framework
we'll have partial types you'll be able to do that.

Bye

--
Lawrence "Rhymes" Oluyede
http://loluyede.blogspot.com
Nov 22 '05 #5

P: n/a
Juarez,
In addition to the others comments: when I need to do this, I consider using
the Replace Method with Method Object refactoring.

http://www.refactoring.com/catalog/r...hodObject.html

Granted you wind up with 2 classes...

Hope this helps
Jay

"Juarez" <an*******@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
Is it possible to divide a class in many .cs files ? For example one source file for each method ?
Thanks.

Nov 22 '05 #6

P: n/a
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.


Why did they need to implement that to do that? Couldnt they just build a
base class which the designer code goes in and then we as users work in the
descendant?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 22 '05 #7

P: n/a
Chad Z. Hower aka Kudzu <cp**@hower.org> wrote:
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
Not yet, but that's a feature which will appear in Whidbey, under the
name "partial types". It's primarily so that you can split
autogenerated code (e.g. forms designer stuff) from manually generated
code.


Why did they need to implement that to do that? Couldnt they just build a
base class which the designer code goes in and then we as users work in the
descendant?


That would be solving a tools problem with a design solution - and the
two should (IMO) rarely mix. If a tool deficiency forces you to make a
suboptimal design (such as having two levels of hierarchy when you
really only want one) then there's something wrong.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #8

P: n/a
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
That would be solving a tools problem with a design solution - and the
two should (IMO) rarely mix. If a tool deficiency forces you to make a
suboptimal design (such as having two levels of hierarchy when you
really only want one) then there's something wrong.


Thats quite a fine line - but I dont see how splitting a class into two files
AND modifying the language to fix a "Tools problem" is better.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 22 '05 #9

P: n/a
Chad Z. Hower aka Kudzu <cp**@hower.org> wrote:
Jon Skeet [C# MVP] <sk***@pobox.com> wrote in
news:MP************************@msnews.microsoft.c om:
That would be solving a tools problem with a design solution - and the
two should (IMO) rarely mix. If a tool deficiency forces you to make a
suboptimal design (such as having two levels of hierarchy when you
really only want one) then there's something wrong.


Thats quite a fine line - but I dont see how splitting a class into two files
AND modifying the language to fix a "Tools problem" is better.


It's better because instead of solving one specific problem, it solves
a range of problems - wherever there's autogenerated code, it's
appropriate. It also keeps the end class design the same, just giving
the option of a slightly less conventional implementation.

I agree it's a fairly fine line, but I know I'd hate to have to have
hierarchies which were too deep just for the sake of the designer.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.