Class across multiple files

  • Thread starter Thread starter Guest
  • Start date Start date
Jay said:
Is it possible to split a class up in multiple files? if so how?

You can, in C# 2.0. Just add the "partial" modifier before each
"class" keyword. Only one partial class has to have the access and
scope modifiers ("public abstract" and the like); if more than one
than one does, all must agree.
 
What was the primary reason for allowing a class to be split across
multiple files? Was it to allow multiple develpers to work on it
simultaneously?

Johann Blake
 
the primary reason is just to have smaller source code files that are easier
to maintain.
 
Johann said:
What was the primary reason for allowing a class to be split across
multiple files? Was it to allow multiple develpers to work on it
simultaneously?

As I understand it, the primary driver was keeping designer-maintained
code (the InitializeComponent method) separate from user-maintained
code (the event handlers and the like).

While we can use it to have Your Part of the class and My Part of the
class, or for versioning (the Silver SKU overrides fewer methods than
the Gold SKU), neither was the intended use, and I've seen ANY manual
use disparaged.
 
Back
Top