How using helps in Garbage collection in C#?
Answers
Answered by
0
Garbage collection in C# can be done through IDisposable interface. But another way of doing garbage collection is the use of using. this way we only have to think about the resource acquisition and the exception handling. the resource release will be done automatically because the resource acquisition is wrapped inside the using block.
The resource release was done automatically. using block is the recommended way of doing such things as it will do the clean up even if the programmers forget to do it.
The use of 'using' block is possible because the TextReader class in the above example is implementing IDisposable
pattern
hope that help you...
The resource release was done automatically. using block is the recommended way of doing such things as it will do the clean up even if the programmers forget to do it.
The use of 'using' block is possible because the TextReader class in the above example is implementing IDisposable
pattern
hope that help you...
Similar questions
Accountancy,
7 months ago
Science,
7 months ago
English,
7 months ago
Science,
1 year ago
Biology,
1 year ago