为什么Inherited AttributeUsage对于DataContractAttribute为false?

时间:2018-09-03 15:10:18

标签: c# datacontract

当我阅读DataContractAttribute源代码时,我注意到AttributeUsage中的Inherited = false。有人知道为什么需要将Inherited设置为false吗?

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, Inherited = false, AllowMultiple = false)]
public sealed class DataContractAttribute : Attribute

1 个答案:

答案 0 :(得分:1)

“ Inherited属性指示继承自应用属性的类的类是否可以继承您的属性。此属性采用true(默认)或false标志。” https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/84c42s56(v=vs.100)

相关问题