C# The ‘new’ keyword on existing objects

In your example, the Red Car instance of c will become eligible for garbage collection when c is assigned to Blue Car. You don’t need to do anything.

Check out this (old, but still relevant) MSDN article about the .NET garbage collector. http://msdn.microsoft.com/en-us/magazine/bb985010.aspx

The first paragraph says it all:

Garbage collection in the Microsoft .NET common language runtime environment completely absolves the developer from tracking memory usage and knowing when to free memory.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)