M
MuZZy
Hi,
Just wanted to make sure i get it right: consider this class:
// =========== START CODE =============
class Test
{
private SqlConnection con = null;
public void Connect()
{
con = new SqlConnection(SomeConnectionString);
<Do something with this connection here>
}
}
// =========== END CODE =============
If i understand right, i don't HAVE TO disconnect explicitly, if i use an object of this class as a
local reference, like here:
// =========== START CODE =============
void SomeFunc()
{
Test t = new Test();
t.Connect();
}
// =========== END CODE =============
"t" should be disposed by GC as the object gets dereferenced right after the line t.Connect()
So technically i don't need to implement Dispose or create/call t.Disconnect, right?
Suggestions would be highly appreciated!
Thank you,
Andrey
Just wanted to make sure i get it right: consider this class:
// =========== START CODE =============
class Test
{
private SqlConnection con = null;
public void Connect()
{
con = new SqlConnection(SomeConnectionString);
<Do something with this connection here>
}
}
// =========== END CODE =============
If i understand right, i don't HAVE TO disconnect explicitly, if i use an object of this class as a
local reference, like here:
// =========== START CODE =============
void SomeFunc()
{
Test t = new Test();
t.Connect();
}
// =========== END CODE =============
"t" should be disposed by GC as the object gets dereferenced right after the line t.Connect()
So technically i don't need to implement Dispose or create/call t.Disconnect, right?
Suggestions would be highly appreciated!
Thank you,
Andrey