如果我宣佈一個靜態的隊列這樣的公共類中:這會造成內存泄漏嗎?
public class c
{
private string[] s={"a","b","c"};
private static Queue<string> q = new Queue<string>(s);
static private void SomeMethod()
{
private string[] s2 = {"123","345"};
// somewhere in here I reassign the queue q = new Queue<string>(s2);
}
}
我的行爲導致C#中的內存泄漏?垃圾回收會追回可能未使用的內存嗎?