Bad practice? Non-canon usage of c#'s using statement

后端 未结 6 1800
广开言路
广开言路 2021-01-01 16:36

C# has the using statement, specifically for IDisposable objects. Presumably, any object specified in the using statement will hold some sort of re

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-01 16:56

    It's a common pattern, but personally, I believe that there's no excuse to abuse IDisposable like that when you can achieve the same effect in a much more obvious way with anonymous delegates and/or lambdas; i.e.:

    blitter.BlitOperation(delegate
    {
       // your code
    });
    

提交回复
热议问题