This content originally appeared on DEV Community and was authored by Joe Enos
Recently C# added "using" statements that can replace "using" blocks in many scenarios. It lets you auto-dispose of a disposable object at the end of the current block, rather than defining a brand new block.
This reduces the number of nested blocks your code needs. It's not unusual to have two nested using blocks, and that pushes your code way over. Now, you just need to structure your code so that it disposes at the end of the block (method, if/else block, old-fashioned using block, even a custom block).
This content originally appeared on DEV Community and was authored by Joe Enos
Joe Enos | Sciencx (2021-05-15T03:38:06+00:00) C# Using Statements. Retrieved from https://www.scien.cx/2021/05/15/c-using-statements/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.