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

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

        <legend id='ptAJw'><style id='ptAJw'><dir id='ptAJw'><q id='ptAJw'></q></dir></style></legend>
          <bdo id='ptAJw'></bdo><ul id='ptAJw'></ul>
      1. <tfoot id='ptAJw'></tfoot>

        为什么对 EventHandler&lt;TEventArgs&gt; 没有约束?

        时间:2023-09-16

      2. <tfoot id='UkEYU'></tfoot>
        <legend id='UkEYU'><style id='UkEYU'><dir id='UkEYU'><q id='UkEYU'></q></dir></style></legend>

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

              <tbody id='UkEYU'></tbody>
              <bdo id='UkEYU'></bdo><ul id='UkEYU'></ul>
            • <i id='UkEYU'><tr id='UkEYU'><dt id='UkEYU'><q id='UkEYU'><span id='UkEYU'><b id='UkEYU'><form id='UkEYU'><ins id='UkEYU'></ins><ul id='UkEYU'></ul><sub id='UkEYU'></sub></form><legend id='UkEYU'></legend><bdo id='UkEYU'><pre id='UkEYU'><center id='UkEYU'></center></pre></bdo></b><th id='UkEYU'></th></span></q></dt></tr></i><div id='UkEYU'><tfoot id='UkEYU'></tfoot><dl id='UkEYU'><fieldset id='UkEYU'></fieldset></dl></div>
                • 本文介绍了为什么对 EventHandler&lt;TEventArgs&gt; 没有约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我只是偶然发现(当编译的东西我认为不会编译时)EventHandler 限制为 System.EventArgs 类型.

                  I just figured out by accident (when something compiled that I didn't think would compile) that EventHandler is not constrained to the type System.EventArgs.

                  这是内联文档:

                  #region Assembly mscorlib.dll, v4.0.0.0
                  // C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5mscorlib.dll
                  #endregion
                  
                  namespace System
                  {
                      // Summary:
                      //     Represents the method that will handle an event.
                      //
                      // Parameters:
                      //   sender:
                      //     The source of the event.
                      //
                      //   e:
                      //     An System.EventArgs that contains the event data.
                      //
                      // Type parameters:
                      //   TEventArgs:
                      //     The type of the event data generated by the event.
                      [Serializable]
                      public delegate void EventHandler<TEventArgs>(object sender, TEventArgs e);
                  }
                  

                  这是文档和实现之间的不匹配吗?

                  Is this a mismatch between docs and implementation?

                  我问是因为我很好奇.这根本不是抱怨.

                  推荐答案

                  .net 4.5 中删除了类型约束.

                  The type constraint was removed in .net 4.5.

                  这是 .net 4.5 签名.http://msdn.microsoft.com/en-us/library/db0etb8x%28v=vs.110%29.aspx

                  Here is the .net 4.5 signature. http://msdn.microsoft.com/en-us/library/db0etb8x%28v=vs.110%29.aspx

                  [SerializableAttribute]
                  public delegate void EventHandler<TEventArgs>(
                      Object sender,
                      TEventArgs e
                  )
                  

                  这是 .net 4.0 签名.http://msdn.microsoft.com/en-us/library/db0etb8x%28v=vs.100%29.aspx

                  Here is the .net 4.0 signature. http://msdn.microsoft.com/en-us/library/db0etb8x%28v=vs.100%29.aspx

                  [SerializableAttribute]
                  public delegate void EventHandler<TEventArgs>(
                      Object sender,
                      TEventArgs e
                  )
                  where TEventArgs : EventArgs
                  

                  这篇关于为什么对 EventHandler&lt;TEventArgs&gt; 没有约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何取消winforms中的任何事件? 下一篇:C#:需要我的一个类来触发另一个类中的事件以更新文本框

                  相关文章

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

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

                      <tfoot id='SSMlq'></tfoot>
                        <bdo id='SSMlq'></bdo><ul id='SSMlq'></ul>
                    1. <small id='SSMlq'></small><noframes id='SSMlq'>