Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

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?

0
indikad
Asked:
indikad
1 Solution
 
joechinaCommented:
I don't think you can assign any value to 'this'
It's readonly.
what do you want to accomplish?
0
 
indikadAuthor Commented:
I wont to get rind of the current instace and create a new instance.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now