If an object realizes IDisposable
in C# one can write
using(DisposableFoo foo = new DisposableFoo())
I've always wondered why the using
looks like a C# keyword, but requires an interface defined in the .Net framework. Is using
a keyword (in this context, obviously it is for defining your library imports), or has Microsoft overloaded it's use in Visual Studio/.Net framework? I wouldn't have expected a C# keyword to depend on a library.
it's a keyword construct that requires a IDisposable, because it acts on the object's Dispose method. It's not too far fetched to have a keyword use a type. If is a keyword and it requires a condition (IE: Boolean) type.
According to Microsoft it's a keyword.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With