Indicates that a type declaration is a partial definition of the type.
You can divide the definition of a type among several declarations by using the Partial keyword. You can use as many partial declarations as you want, in as many different source files as you want. However, all the declarations must be in the same assembly and the same namespace.
Σημείωση
Visual Basic supports partial methods, which are typically implemented in partial classes. For more information, see Partial Methods and Sub Statement.
Required if you use Implements. The names of the interfaces this type implements.
variabledeclarations
Optional. Statements which declare additional variables and events for the type.
proceduredeclarations
Optional. Statements which declare and define additional procedures for the type.
End Class or End Structure
Ends this partial Class or Structure definition.
Remarks
Visual Basic uses partial-class definitions to separate generated code from user-authored code in separate source files. For example, the Windows Form Designer defines partial classes for controls such as Form. You should not modify the generated code in these controls.
All the rules for class, structure, interface, and module creation, such as those for modifier usage and inheritance, apply when creating a partial type.
Best Practices
Under normal circumstances, you should not split the development of a single type across two or more declarations. Therefore, in most cases you do not need the Partial keyword.
For readability, every partial declaration of a type should include the Partial keyword. The compiler allows at most one partial declaration to omit the keyword; if two or more omit it the compiler signals an error.
Behavior
Union of Declarations. The compiler treats the type as the union of all its partial declarations. Every modifier from every partial definition applies to the entire type, and every member from every partial definition is available to the entire type.
Type Promotion Not Allowed For Partial Types in Modules. If a partial definition is inside a module, type promotion of that type is automatically defeated. In such a case, a set of partial definitions can cause unexpected results and even compiler errors. For more information, see Type Promotion.
The compiler merges partial definitions only when their fully qualified paths are identical.
The Partial keyword can be used in these contexts:
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.
.NET σχόλια
.NET είναι ένα έργο ανοιχτού κώδικα. Επιλέξτε μια σύνδεση για να παρέχετε σχόλια:
Συμμετάσχετε στη σειρά meetup για να δημιουργήσετε κλιμακούμενες λύσεις AI που βασίζονται σε πραγματικές περιπτώσεις χρήσης με συναδέλφους προγραμματιστές και ειδικούς.