读取自定义属性

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Tool
{
    public class CustomAttribute
    {
        public static string GetCustomAttribute<T>(Type type) where T:System.Attribute
        {
            return type.GetCustomAttributes(typeof(T), false)[0] as string;
        }
    }

你可能感兴趣的:(自定义)