+ 2
How to delete object ?
C# OOP
5 odpowiedzi
+ 4
oh oh.... I didn't check it properly. Thought it's a c++
+ 3
delete obj;
delete[] array;
+ 2
The delete keyword may be true in C++, though not in C#; no such keyword exists.
Dereference the object by doing
object_name = null;
+ 1
thx mate
0
using (MyIDisposableObject obj = new MyIDisposableObject())
{
// use the object here
} // the object is disposed here
Which is functionally equivalent to:
MyIDisposableObject obj;
try
{
obj = new MyIDisposableObject();
}
finally
{
if (obj != null)
{
((IDisposable)obj).Dispose();
}
}