Creating and using a class attribute.
using System;
using System.Reflection;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class Creator : System.Attribute {
public Creator(string name, string date) {
this.name = name;
this.date = date;
version = 0.1;
}
string date;
string name;
public double version;
}
[Creator("T", "05/01/2001", version = 1.1)]
class MainClass {
static public void Main(String[] args) {
for (int i = 0; i < args.Length; ++i)
System.Console.WriteLine("Args[{0}] = {1}", i, args[i]);
}
}
Related examples in the same category