System.CodeDom.MemberAttributes Enumeration

Defines member attribute identifiers for class members.

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public enum MemberAttributes

Remarks

The identifiers defined in the System.CodeDom.MemberAttributes enumeration can be used to indicate the scope and access attributes of a class member.

Note:

There is no Virtual member attribute. A member is declared virtual by setting its member access to MemberAttributes.Public (property1.Attributes = MemberAttributes.Public) without specifying it as MemberAttributes.Final. The absence of the MemberAttributes.Final flag makes a member virtual in C# (public virtual), overrideable in Visual Basic (Public Overrideable). To avoid declaring the member as virtual or overrideable, set both the MemberAttributes.Public and MemberAttributes.Final flags in the CodeTypeMember.Attributes property. See the CodeTypeMember.Attributes property for more information on setting member attributes.

Note:

The pattern for setting the access flags (flags containing the terms Public, Private, Assembly, or Family) is to mask out all access flags using the MemberAttributes.AccessMask mask and then set the desired access flag. For example, the code statement to identify a constructor (named constructor1) as public is constructor1.Attributes = (constructor1.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;. Setting the CodeTypeMember.Attributes property directly to an access flag (for example, constructor1.Attributes = MemberAttributes.Public;) erases all other flags that might be set. This pattern should also be used for setting the scope flags (MemberAttributes.Abstract, MemberAttributes.Final, MemberAttributes.Static, MemberAttributes.Override or MemberAttributes.Const) using the MemberAttributes.ScopeMask mask.

Members

Member NameDescription
Abstract

An abstract member.

AccessMask

An access mask.

Assembly

A member that is accessible to any class within the same assembly.

Const

A constant member.

Family

A member that is accessible within the family of its class and derived classes.

FamilyAndAssembly

A member that is accessible within its class, and derived classes in the same assembly.

FamilyOrAssembly

A member that is accessible within its class, its derived classes in any assembly, and any class in the same assembly.

Final

A member that cannot be overridden in a derived class.

New

A new member.

Overloaded

An overloaded member. Some languages, such as Visual Basic, require overloaded members to be explicitly indicated.

Override

A member that overrides a base class member.

Private

A private member.

Public

A public member.

ScopeMask

A scope mask.

Static

A static member. In Visual Basic, this is equivalent to the Shared keyword.

VTableMask

A VTable mask.

Requirements

Namespace: System.CodeDom
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0, 4.0.0.0