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

  • <legend id='6Rmu1'><style id='6Rmu1'><dir id='6Rmu1'><q id='6Rmu1'></q></dir></style></legend>

    <small id='6Rmu1'></small><noframes id='6Rmu1'>

      1. <tfoot id='6Rmu1'></tfoot>
        • <bdo id='6Rmu1'></bdo><ul id='6Rmu1'></ul>
      2. 使用自定义属性最简单最优雅的方法是什么

        What#39;s the simplest most elegant way to utilize a custom attribute(使用自定义属性最简单最优雅的方法是什么)

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

          <tfoot id='o83fp'></tfoot>

            <bdo id='o83fp'></bdo><ul id='o83fp'></ul>
          • <legend id='o83fp'><style id='o83fp'><dir id='o83fp'><q id='o83fp'></q></dir></style></legend>

                  <tbody id='o83fp'></tbody>

                1. <i id='o83fp'><tr id='o83fp'><dt id='o83fp'><q id='o83fp'><span id='o83fp'><b id='o83fp'><form id='o83fp'><ins id='o83fp'></ins><ul id='o83fp'></ul><sub id='o83fp'></sub></form><legend id='o83fp'></legend><bdo id='o83fp'><pre id='o83fp'><center id='o83fp'></center></pre></bdo></b><th id='o83fp'></th></span></q></dt></tr></i><div id='o83fp'><tfoot id='o83fp'></tfoot><dl id='o83fp'><fieldset id='o83fp'></fieldset></dl></div>
                2. 本文介绍了使用自定义属性最简单最优雅的方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以有点忏悔,我从来没有写过属性类.我知道它们的目的是用标志或额外的功能装饰类.

                  So a little confession, I've never written an attribute class. I understand they serve the purpose of decorating classes with flags or extra functionality possibly.

                  谁能给我一个简单的例子,不仅可以创建属性并将其应用到类,还可以利用另一个代码块中的属性.我见过的唯一使用任何形式属性的代码示例是通过反射来实现的,尽管我一直希望有一种方法可以在没有反射的情况下使用它们.

                  Can someone give me a quick example of not just creating and applying an attribute to a class, but rather utilizing the attribute from another block of code. The only code samples I've ever seen to utilize any form of attributes was doing so with reflection, though I've always hoped there's a way of using them without reflection.

                  推荐答案

                  属性总是与反射一起使用.它们在编译期间被烘焙到类型的元数据中,读取它们的唯一方法是通过反射.当你想写一个类型并且你想将一些元数据与它相关联时使用属性,这些元数据可以被这种类型的消费者使用.

                  Attributes are always used with reflection. They are baked into the metadata of the types during compile time and the only way to read them is through reflection. Attributes are used when you want write a type and you want to associate some metadata with it which could be used by consumers of this type.

                  这篇关于使用自定义属性最简单最优雅的方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  How can I force the PropertyGrid to show a custom dialog for a specific property?(如何强制 PropertyGrid 显示特定属性的自定义对话框?)
                  Associate attribute with code generated property in .net(将属性与 .net 中的代码生成属性相关联)
                3. <legend id='nlqwW'><style id='nlqwW'><dir id='nlqwW'><q id='nlqwW'></q></dir></style></legend>

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

                          • <small id='nlqwW'></small><noframes id='nlqwW'>

                              <tbody id='nlqwW'></tbody>