Is there something like Python's 'with' in C#? -


Python has a good keyword, because 2.6 is called with . What is the same in C #?

using the same statement

one example Will be

 using  (var reader = new streamrider (path)) {DoSomethingWith (reader); }  

The restriction is that the type of variable scaled by the segment used should be IDisposable and its Dispose () The method is called upon to exit the affiliate code block.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -