, ; someOtherObject using; - .
using (Stream stream = File.OpenRead(@"c:\test.txt"))
{
var v1 = "Hello"; //object declared here, wont be accessible outside the block
stream.Write(ASCIIEncoding.ASCII.GetBytes("This is a test"), 0, 1024);
} //end of scope of stream object; as well as end of scope of v1 object.
v1 = "World!"; //Error, the object is out of scope!
: " v1 ".
.
{
int x=10;
}
x = 20;
See this and this for more help.
source
share