Link to home
Start Free TrialLog in
Avatar of indikad
indikad

asked on

Is it safe to kill the class instance and recreate another within an event in the instance itself? C# .Net

Is it safe to kill the class instance and recreate another within an event in the instance itself?
for example:
I have a class class1
Then in the Main method i instantiate it
class1 MyClass = new class1;

then witin a event procedure inside class1 I want to do this below.
this = null;
MyClass2 = new class1;
// MyClass2 is a ref variable that was passed in .

is this kind of thing safe in C#?
what consequences can I expect?

ASKER CERTIFIED SOLUTION
Avatar of joechina
joechina

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of indikad
indikad

ASKER

I wont to get rind of the current instace and create a new instance.