Attribute

来源:互联网 发布:犀牛设计软件视频教程 编辑:程序博客网 时间:2024/04/28 06:59
using System;using System.Collections.Generic;using System.Linq;using System.Reflection;using System.ServiceModel;using System.ServiceModel.Description;using System.Text;using System.Threading.Tasks;using WcfServiceLibrary1;namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {            MemberInfo info = typeof(Steden).GetProperty("ID"); //GetMethod            TestAttribute t = (TestAttribute)Attribute.GetCustomAttribute(info, typeof(TestAttribute));            Console.WriteLine(t.Name+"====="+t.Paw);        }    }    [Test("A1",Paw ="pp")]    public class Steden    {        [Test("OO",Paw ="OO")]        public void Get()        {        }        [Test("ID", Paw = "ID_Paw")]        public int ID { get; set; }    }    public class TestAttribute : Attribute    {        public TestAttribute(string _name)        {            this.Name = _name;        }        public string Name { get; set; }        public string Paw { get; set; }    }}

0 0
原创粉丝点击