Open and close are not terms used with objects. The line
permissions p = new permissions(intUserID, "cont", strDBConn);//if no userid, user is logged off
will create a new instance of the permissions class. The object will remain in memory until it is no longer referenced. At some indeterminate future point it will be freed by the garbage collector. Since this class is so simple when it is deleted is unimportant.
For classes that represent limited resources or in which you are interested in knowing when they are deleted you should implement the IDisposable interface. This interface notifies clients that they should dispose of the object when they no longer need it. This is done for things like files, streams and database connections. In C# the using statement is used to automate this process.
using(StreamReader sr = new ...) { sr...; }; //sr has been disposed
Note that even though the reader is disposed it is still in memory. However the reader's dispose implementation has internally released any resources it was using. At some future point the reader object itself will be removed from memory.
Michael Taylor - 12/1/06
|