【发布时间】:2012-09-08 11:39:39
【问题描述】:
我正在尝试以下代码:
public partial class Test: Window
{
public Test(ref List</* Type */> LList)
{
[...]
this.ListField = LList;
}
private List</* Type */> ListField;
}
C# 不会在“ListField”中保存引用。 示例:
Test test = new Test(ref /* List</* Type */>-variable*/)
---------
public partial class Test: Window
{
public Test(ref List</* Type */> LList)
{
[...]
this.ListField = LList;
}
private List</* Type */> ListField;
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
ListField = null;
}
}
在关闭表单后,提供给public Test(ref List</* Type */> LList) 的对象没有改变(它不是“null”)。
那么如何在“ListField”中保存引用?
【问题讨论】:
-
很难理解你的意思。代码看起来有效。