473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to separete a class in more than one source file

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

Thanks.

Nov 22 '05 #1
9 1469
[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
[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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
7
by: Juarez | last post by:
Is it possible to divide a class in many .cs files ? For example one source file for each method ? Thanks.
4
by: mchoya | last post by:
I'm so frustrated. I'm beginning school next week and I have been working on a simple program for several days now without being able to complete it. (Though I have brushed up on a lot of C++...
2
by: Matt | last post by:
Hello, I would like to generate what I call an "overall class hierarchy" in UML automatically derived from my C++ code source. An example of what I seek: ...
7
by: A_StClaire_ | last post by:
hi, I'm working on a project spanning five .cpp files. each file was used to define a class. the first has my Main and an #include for each of the other files. problem is my third file...
10
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
20
by: Scott M. | last post by:
What are the advantages of defining a class as part of another class definition (nesting classes)?
15
by: akomiakov | last post by:
Is there a technical reason why one can't initialize a cost static non- integral data member in a class?
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.