Which method do you use to enforce garbage collection in .NET?
In order to enforce garbage collection in .NET, the following method is used:
The System.GC.Collect() method.
The garbage collection GC class provides the GC.Collect method. This method can be used to give the application some direct control over the garbage collector. However, it is recommended that one should avoid calling any of the collect methods, instead allowing the garbage collector to run independently. The reason for this is that the garbage collector is better at determining the best time to perform a collection.