<bdo id='3E2HF'></bdo><ul id='3E2HF'></ul>

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

      <small id='3E2HF'></small><noframes id='3E2HF'>

    2. <legend id='3E2HF'><style id='3E2HF'><dir id='3E2HF'><q id='3E2HF'></q></dir></style></legend>
      1. <tfoot id='3E2HF'></tfoot>

        使用委托会减慢我的 .NET 程序的速度吗?

        Does using delegates slow down my .NET programs?(使用委托会减慢我的 .NET 程序的速度吗?)

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

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

                <tfoot id='vad9g'></tfoot><legend id='vad9g'><style id='vad9g'><dir id='vad9g'><q id='vad9g'></q></dir></style></legend>
                  <tbody id='vad9g'></tbody>

                  <bdo id='vad9g'></bdo><ul id='vad9g'></ul>
                • 本文介绍了使用委托会减慢我的 .NET 程序的速度吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用委托会减慢我的程序速度吗?

                  Does using delegates slow down my programs?

                  我一直在避开它们,因为我真的不知道它们是否会使我的程序变慢.我知道我是否会导致(捕获)异常,这会占用大量 CPU 资源,但我不知道委托和事件以及 .NET 对它们做了什么.

                  I've been avoiding them because I really have no clue if they make my programs any slower. I know if I cause a (catch) exception, that uses quite a bit of CPU power but I don't know about Delegates and Events and what .NET does to them.

                  推荐答案

                  代表非常非常快.不如直接方法调用快,但也不远.它们成为瓶颈的可能性微乎其微.

                  Delegates are very, very fast. Not quite as fast as direct method calls, but not far off. The chances of them becoming a bottleneck are miniscule.

                  (同样的例外情况,如果使用得当,实际上很少会导致性能问题.)

                  (Likewise exceptions, when used properly, rarely actually cause a performance issue.)

                  使用委托会让您的代码更简单、更易读、更健壮吗?如果是这样,请使用它们.仔细衡量你的表现,并密切关注它.仅当数据清晰时才为了性能而远离可读性.

                  Would using delegates make your code simpler, more readable, and more robust? If so, use them. Measure your performance carefully, and keep an eye on it. Move away from readability for the sake of performance only when the data is clear.

                  我确信有一些图表显示了委托、接口和非虚拟方法调用的速度等等——我不知道它们在哪里,但如果你真的担心的话,你总是可以自己运行测试.

                  I'm sure there are some graphs around showing the speed of delegates vs interfaces vs non-virtual method calls etc - I don't know where they are, but you could always run tests yourself if you're really worried.

                  这篇关于使用委托会减慢我的 .NET 程序的速度吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                  Func Delegate vs Function(函数委托与函数)

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

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

                              <tbody id='it83Q'></tbody>