I understand that whenever I create an instance of a class that implements IDisposable, I must use the keyword usingto make sure that it is properly disposed of.
Same:
using (SecureString s = new SecureString())
{
}
This is easy to understand, I can use it s, but I want it in these brackets, but as soon as I leave these brackets, I can no longer refer to s. Scope is easy to see.
But I do not understand how this works when you use usingwithout enclosed brackets.
private void Function()
{
using (SecureString s = new SecureString())
}
You are not required to use parentheses at all ... so ... how do I know where I can use an object and where it will be deleted if there are no parentheses to go with the usingkeyword?