Trying to understand the 'using' statement better

后端 未结 8 1248
小鲜肉
小鲜肉 2021-01-18 17:26

I have read a couple of articles about the using statement to try and understand when it should be used. It sound like most people reckon it should be used as much as possib

8条回答
  •  失恋的感觉
    2021-01-18 17:40

    Personally, I have used at least 3 layers (Connection, Command, Other) a number of times and I see absolutely no problem with it, but as you have already hinted at, eventually there will be a problem a readability. As with other nested constructs, you may need to balance efficiency with maintainability. That is, you don't need to necessarily sacrifice efficiency, but there is often 'more than one way to skin a cat'.

    That said, you would be hard-pushed to generate 10 nested layers!

提交回复
热议问题