Description
The Value
property of the ClassNameAttribute
class is used to store the class name associated with a type or member. This property is a string
and can be accessed publicly. It is not static, virtual, or overridden, meaning it is a straightforward instance property.
Usage
To use the Value
property, you need to create an instance of the ClassNameAttribute
and set the Value
property to the desired class name. This can be useful for metadata purposes, where you want to associate a specific name with a class or member that can be retrieved later using the DisplayInfo library.
Example
// Example of using ClassNameAttribute
[ClassName("MyCustomClassName")]
public class MyClass
{
// Class implementation
}
// Retrieving the class name using DisplayInfo
var classNameAttribute = (ClassNameAttribute)Attribute.GetCustomAttribute(typeof(MyClass), typeof(ClassNameAttribute));
string className = classNameAttribute?.Value;
// className should be "MyCustomClassName"