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

      <bdo id='VVlID'></bdo><ul id='VVlID'></ul>
      1. <tfoot id='VVlID'></tfoot>

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

        如何删除所有事件处理程序

        How to remove all eventhandler(如何删除所有事件处理程序)
        <legend id='VwA8j'><style id='VwA8j'><dir id='VwA8j'><q id='VwA8j'></q></dir></style></legend>

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

            <tbody id='VwA8j'></tbody>
            <bdo id='VwA8j'></bdo><ul id='VwA8j'></ul>

              <tfoot id='VwA8j'></tfoot>
                <i id='VwA8j'><tr id='VwA8j'><dt id='VwA8j'><q id='VwA8j'><span id='VwA8j'><b id='VwA8j'><form id='VwA8j'><ins id='VwA8j'></ins><ul id='VwA8j'></ul><sub id='VwA8j'></sub></form><legend id='VwA8j'></legend><bdo id='VwA8j'><pre id='VwA8j'><center id='VwA8j'></center></pre></bdo></b><th id='VwA8j'></th></span></q></dt></tr></i><div id='VwA8j'><tfoot id='VwA8j'></tfoot><dl id='VwA8j'><fieldset id='VwA8j'></fieldset></dl></div>
                1. 本文介绍了如何删除所有事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我们有一个委托

                  public delegate void MyEventHandler(string x);
                  

                  和一个事件处理程序

                  public event MyEventHandler Something;
                  

                  我们添加多个事件..

                  for(int x = 0; x <10; x++)  
                  {
                     this.Something += HandleSomething;
                  }
                  

                  我的问题是 .. 假设一个人不知道它被添加了 10 次(或更多或更少)次,如何从事件处理程序中删除所有方法?

                  My question is .. how would one remove all methods from the eventhandler presuming one doesn't know its been added 10 (or more or less) times?

                  推荐答案

                  只需将事件设置为null:

                  this.Something = null;
                  

                  它将注销所有事件处理程序.

                  It will unregister all event handlers.

                  这篇关于如何删除所有事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)

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

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

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

                        <tfoot id='YzsyC'></tfoot>

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

                              <tbody id='YzsyC'></tbody>