<small id='elgg0'></small><noframes id='elgg0'>

  • <legend id='elgg0'><style id='elgg0'><dir id='elgg0'><q id='elgg0'></q></dir></style></legend>
    <tfoot id='elgg0'></tfoot>

    <i id='elgg0'><tr id='elgg0'><dt id='elgg0'><q id='elgg0'><span id='elgg0'><b id='elgg0'><form id='elgg0'><ins id='elgg0'></ins><ul id='elgg0'></ul><sub id='elgg0'></sub></form><legend id='elgg0'></legend><bdo id='elgg0'><pre id='elgg0'><center id='elgg0'></center></pre></bdo></b><th id='elgg0'></th></span></q></dt></tr></i><div id='elgg0'><tfoot id='elgg0'></tfoot><dl id='elgg0'><fieldset id='elgg0'></fieldset></dl></div>
    • <bdo id='elgg0'></bdo><ul id='elgg0'></ul>

      1. 如何使 .NET 属性仅对某些类型有效

        How to make .NET attribute only valid on certain types(如何使 .NET 属性仅对某些类型有效)
        • <bdo id='vFZRU'></bdo><ul id='vFZRU'></ul>

          <small id='vFZRU'></small><noframes id='vFZRU'>

              <tbody id='vFZRU'></tbody>
            <legend id='vFZRU'><style id='vFZRU'><dir id='vFZRU'><q id='vFZRU'></q></dir></style></legend>

                <tfoot id='vFZRU'></tfoot>
                  <i id='vFZRU'><tr id='vFZRU'><dt id='vFZRU'><q id='vFZRU'><span id='vFZRU'><b id='vFZRU'><form id='vFZRU'><ins id='vFZRU'></ins><ul id='vFZRU'></ul><sub id='vFZRU'></sub></form><legend id='vFZRU'></legend><bdo id='vFZRU'><pre id='vFZRU'><center id='vFZRU'></center></pre></bdo></b><th id='vFZRU'></th></span></q></dt></tr></i><div id='vFZRU'><tfoot id='vFZRU'></tfoot><dl id='vFZRU'><fieldset id='vFZRU'></fieldset></dl></div>

                  本文介绍了如何使 .NET 属性仅对某些类型有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能重复:
                  指定 .NET 属性目标所需的基类

                  我想指定我的自定义属性仅对某些类型有效(基于接口或基类).
                  像这样:

                  I want to specify that my custom attribute only be valid on certain types (based on interface or base class).
                  Like this:

                  我该怎么做?

                  推荐答案

                  听起来你想创建一个 Attribute,它只能应用于某些类型,就像 AttributeUsage 只能应用于派生自 Attribute 的类型.引入这种类型的自定义限制是不可能的.您看到的特定错误不是因为自定义限制,而是简单地硬连接到编译器本身.

                  It sounds like you want to create an Attribute which can only be applied to certain types in much the way that AttributeUsage can only be applied to types deriving from Attribute. Introducing this type of custom restriction is simply not possible. The particular error you're seeing is not because of a custom restriction, it's one that's simply hard wired into the compiler itself.

                  这篇关于如何使 .NET 属性仅对某些类型有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                  <tfoot id='OOVqt'></tfoot>
                  <i id='OOVqt'><tr id='OOVqt'><dt id='OOVqt'><q id='OOVqt'><span id='OOVqt'><b id='OOVqt'><form id='OOVqt'><ins id='OOVqt'></ins><ul id='OOVqt'></ul><sub id='OOVqt'></sub></form><legend id='OOVqt'></legend><bdo id='OOVqt'><pre id='OOVqt'><center id='OOVqt'></center></pre></bdo></b><th id='OOVqt'></th></span></q></dt></tr></i><div id='OOVqt'><tfoot id='OOVqt'></tfoot><dl id='OOVqt'><fieldset id='OOVqt'></fieldset></dl></div>
                    <legend id='OOVqt'><style id='OOVqt'><dir id='OOVqt'><q id='OOVqt'></q></dir></style></legend>
                      <tbody id='OOVqt'></tbody>
                      • <bdo id='OOVqt'></bdo><ul id='OOVqt'></ul>

                        <small id='OOVqt'></small><noframes id='OOVqt'>