Is it possible to undeclare variables in C#? If so, how?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t take care of undeclaring in C# (I think you mean unallocating by the way, don’t you?) or any other .Net languages, the garbage collector takes care of unallocating the memory associated with the variable.
For unmanaged resources (fonts, database connections, files, etc), you need to call the Dispose method, either explicitely or by placing the variable in an using block.
More information about the .Net garbage collector: http://www.csharphelp.com/2006/08/garbage-collection/