How to garbage collect an object?

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

In my quest to migrate a vb.net app to C# I encountered
the following problem:

session.Initialize("pwrd");
NotesDatabase NotesDB;
NotesDB = session.GetDatabase(server, filename, false);
....
//done with data pulling/processing
NotesDB = Nothing //from vb.net - not working for C#

What should I do about NotesDB = Nothing? If I set

NotesDB = null;

C# doesn't complain, but is this the way to do it?

Thanks,
Ron
 
Ron said:
In my quest to migrate a vb.net app to C# I encountered
the following problem:

session.Initialize("pwrd");
NotesDatabase NotesDB;
NotesDB = session.GetDatabase(server, filename, false);
...
//done with data pulling/processing
NotesDB = Nothing //from vb.net - not working for C#

What should I do about NotesDB = Nothing? If I set

NotesDB = null;

C# doesn't complain, but is this the way to do it?

Not really - if NotesDB is (as it looks) a local variable, there's no
need to set the value to null at all - the garbage collector won't
treat it as a variable which is "in use" after its last use.
 
Back
Top