VB.Net - Modifiers

Advertisements


The modifiers are keywords added with any programming element to give some especial emphasis on how the programming element will behave or will be accessed in the program

For example, the access modifiers: Public, Private, Protected, Friend, Protected Friend, etc., indicate the access level of a programming element like a variable, constant, enumeration or a class.

List of Available Modifiers in VB.Net

The following table provides the complete list of VB.Net modifiers:

S.NModifierDescription
1Ansi Specifies that Visual Basic should marshal all strings to American National Standards Institute (ANSI) values regardless of the name of the external procedure being declared.
2AssemblySpecifies that an attribute at the beginning of a source file applies to the entire assembly.
3Async Indicates that the method or lambda expression that it modifies is asynchronous. Such methods are referred to as async methods. The caller of an async method can resume its work without waiting for the async method to finish.
4Auto The charsetmodifier part in the Declare statement supplies the character set information for marshaling strings during a call to the external procedure. It also affects how Visual Basic searches the external file for the external procedure name. The Auto modifier specifies that Visual Basic should marshal strings according to .NET Framework rules.
5ByRef Specifies that an argument is passed by reference, i.e., the called procedure can change the value of a variable underlying the argument in the calling code. It is used under the contexts of:
  • Declare Statement
  • Function Statement
  • Sub Statement
6ByVal Specifies that an argument is passed in such a way that the called procedure or property cannot change the value of a variable underlying the argument in the calling code. It is used under the contexts of:
  • Declare Statement
  • Function Statement
  • Operator Statement
  • Property Statement
  • Sub Statement
7Default Identifies a property as the default property of its class, structure, or interface.
8Friend Specifies that one or more declared programming elements are accessible from within the assembly that contains their declaration, not only by the component that declares them.
Friend access is often the preferred level for an application's programming elements, and Friend is the default access level of an interface, a module, a class, or a structure.
9In It is used in generic interfaces and delegates.
10Iterator Specifies that a function or Get accessor is an iterator. An iterator performs a custom iteration over a collection.
11Key The Key keyword enables you to specify behavior for properties of anonymous types.
12Module Specifies that an attribute at the beginning of a source file applies to the current assembly module. It is not same as the Module statement.
13MustInherit Specifies that a class can be used only as a base class and that you cannot create an object directly from it.
14MustOverride Specifies that a property or procedure is not implemented in this class and must be overridden in a derived class before it can be used.
15Narrowing Indicates that a conversion operator (CType) converts a class or structure to a type that might not be able to hold some of the possible values of the original class or structure.
16NotInheritableSpecifies that a class cannot be used as a base class.
17NotOverridableSpecifies that a property or procedure cannot be overridden in a derived class.
18Optional Specifies that a procedure argument can be omitted when the procedure is called.
19Out For generic type parameters, the Out keyword specifies that the type is covariant.
20OverloadsSpecifies that a property or procedure redeclares one or more existing properties or procedures with the same name.
21Overridable Specifies that a property or procedure can be overridden by an identically named property or procedure in a derived class.
22Overrides Specifies that a property or procedure overrides an identically named property or procedure inherited from a base class.
23ParamArray ParamArray allows you to pass an arbitrary number of arguments to the procedure. A ParamArray parameter is always declared using ByVal.
24Partial Indicates that a class or structure declaration is a partial definition of the class or structure.
25PrivateSpecifies that one or more declared programming elements are accessible only from within their declaration context, including from within any contained types.
26Protected Specifies that one or more declared programming elements are accessible only from within their own class or from a derived class.
27PublicSpecifies that one or more declared programming elements have no access restrictions.
28ReadOnly Specifies that a variable or property can be read but not written.
29Shadows Specifies that a declared programming element redeclares and hides an identically named element, or set of overloaded elements, in a base class.
30Shared Specifies that one or more declared programming elements are associated with a class or structure at large, and not with a specific instance of the class or structure.
31Static Specifies that one or more declared local variables are to continue to exist and retain their latest values after termination of the procedure in which they are declared.
32UnicodeSpecifies that Visual Basic should marshal all strings to Unicode values regardless of the name of the external procedure being declared.
33Widening Indicates that a conversion operator (CType) converts a class or structure to a type that can hold all possible values of the original class or structure.
34WithEvents Specifies that one or more declared member variables refer to an instance of a class that can raise events.
35WriteOnlySpecifies that a property can be written but not read.


Advertisements
Advertisements