How to splitt a large class into two or more files ?

  • Thread starter Thread starter Heinz Zimmermann
  • Start date Start date
H

Heinz Zimmermann

Hello,
is it (in c#) possible, to splitt a large class into two or more files ?
If yes, how can I do that ?

Thanks
Heinz
 
Heinz Zimmermann said:
is it (in c#) possible, to splitt a large class into two or more files ?

Not at the moment. It will be in Whidbey (the next version).
If yes, how can I do that ?

Can I ask why your class is very large in the first place? It's
*usually* (but not always) a sign that you need to split your class
into more classes to start with.
 
my problem is:
i have a namespace, say "MyControls"
in this namespace there are is a control "TheControl" and numerous helper
classes and enumerations belonging to this control
what i want to do:
in class browser, only the main class (the control) should be visible, all
helper classes are reachable by MyControls.TheControl.MyHelperClass
i see two possibilities:

1. namespace: i can't create a namespace MyControls.TheControl if there
already is a class MyControls.TheControl
2. embedded classes: if i make all the helper classes embedded classes of
the main class MyControls.TheControl, then the TheControl.cs file explodes
because i have to merge in all Helper cs files

or is there another way to reach this?
 
Heinz Zimmermann said:
my problem is:
i have a namespace, say "MyControls"
in this namespace there are is a control "TheControl" and numerous helper
classes and enumerations belonging to this control
what i want to do:
in class browser, only the main class (the control) should be visible, all
helper classes are reachable by MyControls.TheControl.MyHelperClass
i see two possibilities:

1. namespace: i can't create a namespace MyControls.TheControl if there
already is a class MyControls.TheControl
2. embedded classes: if i make all the helper classes embedded classes of
the main class MyControls.TheControl, then the TheControl.cs file explodes
because i have to merge in all Helper cs files

or is there another way to reach this?

If you have a load of helper classes, you might even consider moving to
a separate assmebly for each control, and have those helper classes as
internal. Otherwise, you could certainly change to group your controls
by namespace, or even have MyControls.Helpers for internal helper
classes. That unfortunately doesn't give the same level of protection
as having them private to the containing class, of course.
 
Back
Top