您的位置:首页 > 其它

所有可以定制的特性是什么?

2006-10-31 16:35 197 查看
using System;

public class MyAttribute : Attribute
{
public MyAttribute(int i)
{
}
}
//[assembly:MyAttribute(1)]
//[module:MyAttribute(2)]
//应用于类型
[type: MyAttribute(3)]
class MyType
{

int _age;

//应用于属性

[property: MyAttribute(4)]

public int Age
{

get { return _age; }

set { _age = value; }

}

//应用于事件

[event: MyAttribute(5)]

public event EventHandler MyHandler;

//应用于字段上

[field: MyAttribute(6)]

public int fieldMember;

//应用于返回值

[return: MyAttribute(7)]

//应用于方法

[method: MyAttribute(8)]

//应用于方法参数

public Int32 MyMethod([param: MyAttribute(9)]Int32 someParam)
{

return someParam;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐