How do i free objects in C#

后端 未结 9 1733
傲寒
傲寒 2021-01-01 21:53

Can anyone please tell me how I can free objects in C#? For example, I have an object:

Object obj1 = new Object();
//Some code using obj1
/*
Here I would l         


        
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-01 22:40

    You can use the using statement. After the scope the reference to the object will be removed and garbage collector can collect it at a later time.

提交回复
热议问题