B
Benjamin Fallar III
Hi,
I would like to concrete my understanding about my custom object using an
ADO.NET connection object and the behavior of garbage collector.
I have a simple .NET object
public class DBACCESS
{
public void OpenConnection()
{
SqlConnection cn = new SqlConnection(connection_string);
// some code here
}
}
Here is my client code;
DBACCESS db1 = new DBACCESS();
db1.OpenConnection();
db1 = null;
Now, I would like to confirm that when the GC collected my db1 object, will
it also close/release the connection object used by the object instantiated
by my client code (which is the db1)?
Thanks!
I would like to concrete my understanding about my custom object using an
ADO.NET connection object and the behavior of garbage collector.
I have a simple .NET object
public class DBACCESS
{
public void OpenConnection()
{
SqlConnection cn = new SqlConnection(connection_string);
// some code here
}
}
Here is my client code;
DBACCESS db1 = new DBACCESS();
db1.OpenConnection();
db1 = null;
Now, I would like to confirm that when the GC collected my db1 object, will
it also close/release the connection object used by the object instantiated
by my client code (which is the db1)?
Thanks!