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

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

      1. <tfoot id='dMzLN'></tfoot>
        <legend id='dMzLN'><style id='dMzLN'><dir id='dMzLN'><q id='dMzLN'></q></dir></style></legend>

        我可以按类型获取 C# 委托的签名吗?

        时间:2023-11-11

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

          • <small id='9zMcr'></small><noframes id='9zMcr'>

              <tbody id='9zMcr'></tbody>
                  <bdo id='9zMcr'></bdo><ul id='9zMcr'></ul>
                  <tfoot id='9zMcr'></tfoot>
                • 本文介绍了我可以按类型获取 C# 委托的签名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果您有委托的类型信息,是否有一种直接的方法使用反射来获取委托的参数列表?

                  Is there a straightforward way using reflection to get at the parameter list for a delegate if you have its type information?

                  例如,如果我声明一个委托类型如下

                  For an example, if I declare a delegate type as follows

                  delegate double FooDelegate (string param, bool condition);
                  

                  稍后获取该委托类型的类型信息,如下所示

                  and later get the type information for that delegate type as follows

                  Type delegateType = typeof(FooDelegate);
                  

                  是否可以从该类型信息对象中检索返回类型 (double) 和参数列表 ({string, bool})?

                  Is it possible to retrieve the return type (double) and parameter list ({string, bool}) from that type info object?

                  推荐答案

                      MethodInfo method = delegateType.GetMethod("Invoke");
                      Console.WriteLine(method.ReturnType.Name + " (ret)");
                      foreach (ParameterInfo param in method.GetParameters()) { 
                          Console.WriteLine("{0} {1}", param.ParameterType.Name, param.Name);
                      }
                  

                  这篇关于我可以按类型获取 C# 委托的签名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:从 MethodInfo 构建一个委托? 下一篇:List&lt;object&gt;.RemoveAll - 如何创建适当的谓词

                  相关文章

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

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

                    1. <small id='zXFo3'></small><noframes id='zXFo3'>