Extending VB.NET class definition across multiple files

To organize the various methods of my MainForm class, I would like to classify them into multiple files. Of course, these methods will still need to access the form elements and additional variables that I added to the MainForm class.

What is the standard / best way to do this?

+3
source share
3 answers

This can be done using Partial classes .

An alternative way to structure code inside a file Regions .

Of course, if your class code is so large that it needs to be split into several files, you may need to reorganize it into several classes.

+3

,

+2

A simple answer would be to use partial classes. This does not tell you the best practices for your application.

I would recommend reading Microsoft.NET: Architectural Enterprise Applications http://www.amazon.com/Microsoft-NET-Architecting-Applications-PRO-Developer/dp/073562609X

You can download the source code that comes with the book from codeplex. Just find nsk.

The source code becomes clearer after reading the book.

+1
source

Source: https://habr.com/ru/post/1732198/


All Articles