• <bdo id='h2RfN'></bdo><ul id='h2RfN'></ul>

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

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

      <tfoot id='h2RfN'></tfoot>

      1. 是否可以将属性添加到部分类中的属性?

        Is it possible to add an attribute to a property in a partial class?(是否可以将属性添加到部分类中的属性?)
        <tfoot id='eNQ1O'></tfoot>

      2. <small id='eNQ1O'></small><noframes id='eNQ1O'>

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

              • <bdo id='eNQ1O'></bdo><ul id='eNQ1O'></ul>
                1. 本文介绍了是否可以将属性添加到部分类中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我不认为这是可能的,但由于我没有从 MSDN 得到明确的说明,我觉得最好问问.假设我们有一个如下的类.

                  I don't think it's possible but since I haven't got a definite clarity from MSDN, I feel that it's best to ask. Suppose that we have a class as follows.

                  public partial class Hazaa
                  {
                    public int Shazoo { get; set; }
                  }
                  

                  然后,我希望将 Shazoo 归为 SuperCool 我希望在另一个文件中这样做.由于我使用的是部分类,因此我可以按如下方式添加新属性.

                  Then, I'd like Shazoo to be attributed as SuperCool but I wish to do so in another file. Since I'm using partial classes, I can add new properties as follows.

                  public partial class Hazaa
                  {
                    [SuperCool]
                    public int Wheee { get; set; }
                  }
                  

                  但是我可以通过在第一个示例中编写代码来为第一个示例中声明的属性赋予属性吗?我怀疑这是可能的,但我很乐意接受纠正.如果是这样,语法是什么?

                  But can I attribute a property declared in the first sample by writing code in the latter? I doubt it's possible but I'll be glad to stand corrected. If so, what's the syntax?

                  推荐答案

                  不,你不能.

                  您只能将属性附加到您在那里声明的成员,然后,除非该成员也被声明为部分(以便您可以在其他地方重新实现它),否则您不能将属性附加到另一个部分文件中声明的成员.

                  You can only attach attributes to members you declare there and then, and unless the member is also declared as partial (so that you may reimplement it elsewhere) you cannot attach attributes to members declared in another partial file.

                  这篇关于是否可以将属性添加到部分类中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 中的代码生成属性相关联)

                2. <i id='qgGR8'><tr id='qgGR8'><dt id='qgGR8'><q id='qgGR8'><span id='qgGR8'><b id='qgGR8'><form id='qgGR8'><ins id='qgGR8'></ins><ul id='qgGR8'></ul><sub id='qgGR8'></sub></form><legend id='qgGR8'></legend><bdo id='qgGR8'><pre id='qgGR8'><center id='qgGR8'></center></pre></bdo></b><th id='qgGR8'></th></span></q></dt></tr></i><div id='qgGR8'><tfoot id='qgGR8'></tfoot><dl id='qgGR8'><fieldset id='qgGR8'></fieldset></dl></div>
                3. <legend id='qgGR8'><style id='qgGR8'><dir id='qgGR8'><q id='qgGR8'></q></dir></style></legend>

                    • <bdo id='qgGR8'></bdo><ul id='qgGR8'></ul>

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

                              <tbody id='qgGR8'></tbody>
                            <tfoot id='qgGR8'></tfoot>