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

email - PHP mail error ... failed to open stream : permission denied -

c# - ListView onScroll event -

c - Linux mmap() error -