Creating and using a class attribute. : Attribute : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Attribute »

 

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]);

    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Attribute