コード例 #1
0
        static void Main(string[] args)
        {
            Attribute a = Attribute.GetCustomAttribute(
                typeof(Person), typeof(ProgrammerAttribute));

            ProgrammerAttribute p = (ProgrammerAttribute)a;

            Console.WriteLine("Programmer: {0}", p.Programmer);

            Console.ReadKey();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: hcostapuc/70-483
        static void Main(string[] args)
        {
            //CTO: GetCustomAttribute tem os mesmos parametros que o IsDefined, ao invez de retornar um booleano ele retorna a referencia do atributo buscado, se nao existir ele retorna null
            Attribute a = Attribute.GetCustomAttribute(
                typeof(Person), typeof(ProgrammerAttribute));

            ProgrammerAttribute p = (ProgrammerAttribute)a;

            Console.WriteLine("Programmer: {0}", p.Programmer);

            Console.ReadKey();
        }