예제 #1
0
        static void Main()
        {
            Type t = typeof(UseAttrib);

            Console.Write("Атрибуты в классе " + t.Name + ": ");
            object[] attribs = t.GetCustomAttributes(false);
            foreach (object o in attribs)
            {
                Console.WriteLine(o);
            }
            Console.Write("Примечание: ");

            // Извлечь атрибут RemarkAttribute
            Type            tRemAtt = typeof(RemarkAttribute);
            RemarkAttribute ra      = (RemarkAttribute)Attribute.GetCustomAttribute(t, tRemAtt);

            Console.WriteLine(ra.Remark);
        }
예제 #2
0
        static void Main()
        {
            Type t = typeof(UseAttrib);

            Console.Write("Атрибуты в классе " + t.Name + ": ");
            object[] attribs = t.GetCustomAttributes(false);
            foreach (object o in attribs)
            {
                Console.WriteLine(o);
            }
            // Извлечь атрибут RemarkAttribute.
            Type            tRemAtt = typeof(RemarkAttribute);
            RemarkAttribute ra      = (RemarkAttribute)Attribute.GetCustomAttribute(t, tRemAtt);

            Console.Write("Примечание: ");
            Console.WriteLine(ra.Remark);

            Console.Write("Дополнительно: ");
            Console.WriteLine(ra.Supplement);

            Console.WriteLine("Приоритет: " + ra.Priority);
        }