RE: Generic Dispose Function?
From: TT (Tom Tempelaere) (_N_0SPAMtiti_____at_hotmail.comMAPS0_N_)
Date: 03/22/04
- Next message: Stoitcho Goutsev \(100\) [C# MVP]: "Re: : )"
- Previous message: Morten Wennevik: "Re: Mousemove, handles, control problem"
- In reply to: Jeff: "Generic Dispose Function?"
- Next in thread: Shawn B.: "Re: Generic Dispose Function?"
- Reply: Shawn B.: "Re: Generic Dispose Function?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Mar 2004 08:01:10 -0800
Which is foolish, because in C++ the following is completely ok:
SomeCls* sc = NULL;
delete sc; // has no effect.
You don't ever need to test for NULL-ness when deleting in c++.
Tom.
----- Jeff wrote: -----
In C++ I used to declare the following macro for deleteing objects:
#define SAFEDELETE(x) if(x != NULL) { delete x; x = NULL; }
Is there currently a way to do something similar to this in C#?
I'm constantly writing...
if(x != null)
{
x.Dispose();
x = null;
}
and would love to just write something like...
SAFEDISPOSE(x);
Thanks for your help!
- Next message: Stoitcho Goutsev \(100\) [C# MVP]: "Re: : )"
- Previous message: Morten Wennevik: "Re: Mousemove, handles, control problem"
- In reply to: Jeff: "Generic Dispose Function?"
- Next in thread: Shawn B.: "Re: Generic Dispose Function?"
- Reply: Shawn B.: "Re: Generic Dispose Function?"
- Messages sorted by: [ date ] [ thread ]