<legend id='yjTiP'><style id='yjTiP'><dir id='yjTiP'><q id='yjTiP'></q></dir></style></legend>

  • <tfoot id='yjTiP'></tfoot>

        <bdo id='yjTiP'></bdo><ul id='yjTiP'></ul>

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

      2. C# 动态属性参数

        C# Dynamic Attribute Arguments(C# 动态属性参数)
          <tbody id='Ir6h6'></tbody>
        <tfoot id='Ir6h6'></tfoot>

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

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

                  本文介绍了C# 动态属性参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有没有办法做到以下几点?我看到属性参数必须是一个常量表达式,那么我将如何解决这个问题?如果我不想使用绑定将 一些 属性加载到 datagridview 中,那么下一个最佳选择是什么?

                  Is there a way to do the following? I see that the Attribute Arguments must be a constant expression, so how would I work around this? If I dont want to load some properties into a datagridview using binding, whats the next best alternative?

                    class TestObj
                    {
                       private bool isBrowsable = false;
                  
                       [Browsable(isBrowsable)]
                       public string String1
                       {
                          get
                          {
                             return "Foo";
                          }
                       }
                       [Browsable(isBrowsable)]
                       public string String2
                       {
                          get
                          {
                             return "Baz";
                          }
                       }
                    }
                  

                  推荐答案

                  您可以通过实现 ICustomTypeDescriptor 接口 - 但这是一项相当多的工作,并不像用属性装饰属性那么简单.

                  You can provide dynamic custom type information at runtime by implementing the ICustomTypeDescriptor interface - but this is quite a bit of work at not nearly as simple as decorating properties with attributes.

                  这篇关于C# 动态属性参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 中的代码生成属性相关联)
                    <legend id='cCj63'><style id='cCj63'><dir id='cCj63'><q id='cCj63'></q></dir></style></legend>

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

                            <tbody id='cCj63'></tbody>

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

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