日期:2014-05-17  浏览次数:20974 次

关于C# GetCustomAttributes的疑惑求解答!
这个是返回得到自定义属性的Object数组,的第一个参数官方说是指定的类型
在这个例子中返回的是得到什么的类型的自定义属性
object[] attribs = f.GetCustomAttributes(typeof(ConfigPropertyAttribute), false);


using System;
namespace Game.Base.Config
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public class ConfigPropertyAttribute : Attribute{
private string m_key;
private string m_description;
private object m_defaultValue;
        public ConfigPropertyAttribute(string key, string description, object defaultValue)
           {
m_key = key;
m_description = description;
m_defaultValue = defaultValue;
}
public string Key{get{return m_key;}}
public string Description{get{return m_description;}}
public object DefaultValue{get{return m_defaultValue;}}
    }
}

C#

------解决方案--------------------
ConfigPropertyAttribute类型的啊
------解决方案--------------------
具体可以查看MSDN的介绍了,另外推荐这篇博客给你学习:http://www.cnblogs.com/wenwuxianren/articles/950186.html