有没有办法在 C# 中执行以下操作?
List<int> aList = new List<int>();
List<int> bList = new List<int>();
... // fill the list somehow
List<int> referece; //?????
if (doThis)
referece = aList;
else
referece = bList;
reference= .... assign another list to reference
这在 C# 中可能吗?在 C++ 中,我会参考一个列表,但在 C# 中?
编辑:我纠正了我的例子。想法是,我想用新的/不同的列表替换列表,并且我想更改 aList 或 bList。当我分配一个新列表来引用时,aList 和 bList 不会改变。但这就是我真正想要的,更改 aList 或 bList。参考只是选择保存列表的变量。