Marc

Marc

  • NA
  • 205
  • 54.1k

Setting an instance to null

Oct 16 2014 8:49 AM
I have a decrypter that returns a decrypted value and decrypted catagory. If for some reason my program cannot find the catagory is it best to set the instance of the catagory to null or dispose it?  This way I can still provide the decrypted value, but not the decrypted catagory.  Below is what I have done thus far.....
 
GetKey key = GetKey.Instace[category.ToLower()];
 
bool ctgry = key.DoesCategoryExist(category.ToLower());
if (ctgry == false)
{
//key.dispose();
key = null;  // which should work best?
 
}

I am also trying to log the fact that no category exists within the if statement or upon the diposel of key without throwing an exemption. 

Answers (2)