This is similar to the same restriction placed on properties.
Partial Classes
Partial classes were added in VB 2005. So far, you??™ve seen how to define classes in one single
file, and until VB 2005, it was impossible to split the definition of a class across multiple files.
At first, such a convenience may not seem worthwhile. After all, if a class has become so large
that the file is hard to manage, that may be an indication of poor design. But arguably, the
main reason partial classes were introduced is to support code-generation tools.
Normally, when you work within the confines of the IDE, the IDE tries to help you out by
generating some code for you. For example, a wizard generates helpful DataSet derived classes
when using ADO.NET facilities. The classic problem has always been editing the resulting
code generated by the tool. It was always a dangerous proposition to edit the output from the
tool because any time the parameters to the tool change, the tool regenerates the code, thus
overwriting any changes made. This is definitely not desired. Previously, the only way to work
around this was to use some form of reuse, such as inheritance or containment, thus inheriting
a class from the class produced by the code-generation tool.
Pages:
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106