Query about initialization of objects created within a static method by the garbage collector

22 views Asked by At

I have a question regarding the behavior of the garbage collector in C#.

I tried writing a simple code and testing it, but it returned null. I'm not sure about the details.

public static void Test()
{
    Dictionary<string, string> dic = new Dictionary<string, string>();
    dic.Add("test", "test");
}

static void Main(string[] args)
{
    Test();
    while (true)
    {
       
    }
}

0

There are 0 answers