有没有办法强制编译器限制自定义属性的使用仅用于特定属性类型,如int,short,string(所有基本类型)? 类似于AttributeUsageAttribute的ValidOn- AttributeTargets枚举.
.net c# compiler-construction attributes
可能重复: 指定.NET属性目标所需的基类
我想指定我的自定义属性仅对某些类型有效(基于接口或基类). 像这样:
我怎样才能做到这一点?
.net c# attributes
.net ×2
attributes ×2
c# ×2
compiler-construction ×1