Solved

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

Posted on 2008-06-15
2
269 Views
Last Modified: 2008-06-29
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
Comment
Question by:indikad
2 Comments
 
LVL 13

Accepted Solution

by:
joechina earned 250 total points
ID: 21793712
I don't think you can assign any value to 'this'
It's readonly.
what do you want to accomplish?
0
 

Author Comment

by:indikad
ID: 21842871
I wont to get rind of the current instace and create a new instance.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now