That code is nonsensical. virtual is a reserved keyword.
Compiler errors are the most simple errors to solve. Every programmer starts out this way, eventually the compiler stops nagging and you can start to encounter real problems. I suggest that you take the time to read the error message and do a little research to figure out why it is happening.
Destructors are methods or functions. Its used to exit from the object execution gracefully. So, if you have used recsources, its a good practice to dispose them off after you're done with the object. Dispose as such is used to dispose objects by the .NET runtime. You call Dispose() of resources which implements IDisposable , that will release back the memory it once occupied. GC does that periodically, but its good, if your object has consumed a lot of resources, then release it once the object is done with what its doing.
Note that GC is called by runtime periodically based on a no. of factors, so there is no guarantee the resources would be released at any point of time. System.GC() to make it collect, or use the destructor to free all the resources used.
Destructors are methods or functions. Its used to exit from the object execution gracefully. So, if you have used recsources, its a good practice to dispose them off after you're done with the object. Dispose as such is used to dispose objects by the .NET runtime. You call Dispose() of resources which implements IDisposable , that will release back the memory it once occupied. GC does that periodically, but its good, if your object has consumed a lot of resources, then release it once the object is done with what its doing.
Well, that's not really true. IDisposable has nothing to do with releasing the memory consumed by .NET objects, it is all about releasing native resources that will not be cleaned up automatically by the runtime (i.e., file handles, DIBs, DC's, etc.)
The whole point is that it gives you deterministic deallocation of resources. The finalizer of .NET objects *will* in fact release these resources, it is simply non-deterministic.
Also, please, please, do not call GC.Collect( ) unless you have *proven* that it is necessary for your situation, which it rarely is.
Last edited by BigEd781; July 20th, 2010 at 03:15 PM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.