static void DisplayCustomAttribute(CustomAttrDemo cattDemo) { Type type = cattDemo.GetType(); Object obj = type.GetCustomAttributes(false)[0]; if(obj is CodeInfoAttribute) { System.Console.Write("Developer - "); System.Console.WriteLine(((CodeInfoAttribute)obj).Devloper); System.Console.Write("Reviewer - "); System.Console.WriteLine(((CodeInfoAttribute)obj).Reviewer); System.Console.Write("Review Date - "); System.Console.WriteLine(((CodeInfoAttribute)obj).ReviewDate); } else System.Console.WriteLine("Attribute not found"); }
static void Main(string[] args) { CustomAttrDemo cattDemo = new CustomAttrDemo(); DisplayCustomAttribute(cattDemo); }