How to delete object?

前端 未结 9 1316
眼角桃花
眼角桃花 2021-02-13 18:39

I need to create a method of class that delete the instance.

public class Car
{
    private string m_Color;

    public string Color
    {
        get { return m         


        
9条回答
  •  闹比i
    闹比i (楼主)
    2021-02-13 18:48

    What you're asking is not possible. There is no mechanism in .Net that would set all references to some object to null.

    And I think that the fact that you're trying to do this indicates some sort of design problem. You should probably think about the underlying problem and solve it in another way (the other answers here suggest some options).

提交回复
热议问题