Disposables, Using & Try/Catch Blocks

后端 未结 6 1393
一向
一向 2020-12-19 05:56

Having a mental block today, need a hand verifying my logic isn\'t fubar\'ed.

Traditionally I would do file i/o similar to this:

FileStream fs = null         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 06:32

    You don't need the try..finally if you have a using(). They perform the same operation.

    If you're not convinced, point Reflector at your assembly and compare the generated code.

提交回复
热议问题