C
Cybertof
Hi !
I'm wondering about the use of the 'using' statement.
In a procedure, should i declare all instance variables in a using
clause ?
In the below code, what would happen if MyFont & MyFont2 would be
declared in the body of the Main() and not inside the using (even not
referenced in the using) ? Would be there something to call to dispose
them ?
I thought the garbage collector was doing all this by itself...
***********
code sample
***********
using System.Drawing;
class a
{
public static void Main()
{
using (Font MyFont = new Font("Arial", 10.0f), MyFont2 = new Font
("Arial", 10.0f))
{
// use MyFont and MyFont2
} // compiler will call Dispose on MyFont and MyFont2
Font MyFont3 = new Font("Arial", 10.0f);
using (MyFont3) // WHAT HAPPEN IF no using here ???
{
// use MyFont3
} // compiler will call Dispose on MyFont3
}
}
Regards,
Cybertof.
I'm wondering about the use of the 'using' statement.
In a procedure, should i declare all instance variables in a using
clause ?
In the below code, what would happen if MyFont & MyFont2 would be
declared in the body of the Main() and not inside the using (even not
referenced in the using) ? Would be there something to call to dispose
them ?
I thought the garbage collector was doing all this by itself...
***********
code sample
***********
using System.Drawing;
class a
{
public static void Main()
{
using (Font MyFont = new Font("Arial", 10.0f), MyFont2 = new Font
("Arial", 10.0f))
{
// use MyFont and MyFont2
} // compiler will call Dispose on MyFont and MyFont2
Font MyFont3 = new Font("Arial", 10.0f);
using (MyFont3) // WHAT HAPPEN IF no using here ???
{
// use MyFont3
} // compiler will call Dispose on MyFont3
}
}
Regards,
Cybertof.