Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CustomConstantAttribute Class

Defines a constant value that a compiler can persist for a field or method parameter.

For a list of all members of this type, see CustomConstantAttribute Members.


[Visual Basic]
<AttributeUsage(AttributeTargets.Field Or _
MustInherit Public Class CustomConstantAttribute
   Inherits Attribute
[AttributeUsage(AttributeTargets.Field |
public abstract class CustomConstantAttribute : Attribute
[AttributeUsage(AttributeTargets::Field |
public __gc __abstract class CustomConstantAttribute : public
   AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter)
abstract class CustomConstantAttribute extends Attribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


You can apply this attribute to fields or parameters.

This class cannot be instantiated.

Compilers should create specific classes, derived from this class, that define the type of the constant value. For example, see the DateTimeConstantAttribute which allows a compiler to persist an 8-byte DateTime constant for a field or method parameter. If you are using System.Reflection, this pattern of deriving specific classes from CustomConstantAttribute enables you to find all occurances of custom constant attributes easily.

The classes in System.Runtime.CompilerServices are for compiler writers use only.


Namespace: System.Runtime.CompilerServices

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: Mscorlib (in Mscorlib.dll)

See Also

CustomConstantAttribute Members | System.Runtime.CompilerServices Namespace

© 2017 Microsoft