コード例 #1
0
ファイル: UnitTest3.cs プロジェクト: Kyou12138/CommonUtils
        public void demo16()
        {
            Type t = typeof(TestA);
            var  a = t.GetCustomAttributes();

            foreach (var item in a)
            {
                ReviewCommentAttribute att = item as ReviewCommentAttribute;
                Console.WriteLine(att.TypeId);
                Console.WriteLine(att.Description);
                Console.WriteLine(att.VersionNumber);
                Console.WriteLine(att.ReviewerId + "end");
            }
        }
コード例 #2
0
    static void Main()
    {
        Type t = typeof(MyClass);

        object[] AttArr = t.GetCustomAttributes(false);
        foreach (Attribute a in AttArr)
        {
            ReviewCommentAttribute attr = a as ReviewCommentAttribute;
            if (null != attr)
            {
                Console.WriteLine("Description    : {0}", attr.Description);
                Console.WriteLine("Version Number : {0}", attr.VersionNumber);
                Console.WriteLine("Reviewer ID    : {0}", attr.ReviewerID);
            }
        }
    }