How to break a VB. NET class into multiple files

Source: Internet
Author: User

The patial keyword of VB. Net allows you to break a long class into multiple physical source files. Pass this articleArticleTo learn more about how to use the partial keyword.CodeExample.

Today, with the complexity of application software, developers often need to deal with some very long classes. One way to manage these classes is to divide these classes into multiple files. Partial is a New Keyword introduced by VB. NET. It allows you to divide a class into multiple physical source files. You can also use the partial keyword to define a class with multiple files.

Generally, there are many developers in large projects. These developers may operate on the same class at the same time, at this time, breaking a class into multiple source files is more conducive for developers to operate on the same class at the same time, or when these classes are defined too long, splitting it into multiple files makes it easier to process.

You need to use the partial keyword to tell the VB compiler to collect all the parts of the class before creating the class. If you use multiple files, you do not need to use this keyword in every place of the Class-you only need to use it in one place. However, all blocks of the same class must be defined in the same namespace.

The compiler regards the class as a set of all part declarations. Each modifier of each part can apply a complete class.

Note:If the class you use inherits from other classes or implements an interface, you only need to use the inherits or implements keyword in a part of the class.

PartialExample

Class longclass1

'Class members defined here

End Class

Partial class longclass1

'Additional Class Members defined here

End Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.