简体   繁体   English

如何将一个列表中的项目添加到另一个列表

[英]How to add an item from a list to another list

I have a list called "enctypechances" and I want to give the item "Land" to another list. 我有一个名为“ enctypechances”的列表,我想将“ Land”项分配给另一个列表。

public static List<Encounter> enctypechances = new List<Encounter>();
Encounter Land = new Encounter(20, 20, 10, 10, 10, 10, 5, 5, 4, 4, 1, 1);

Here is where I want to add the "Land" item 这是我要添加“土地”项目的地方

List<Encounter> enctypes = new List<Encounter>();

void Start () {
    enctypes.Add( ??? );
}

Land has to be visible within the start() scope. Land必须在start()范围内可见。 You have to declare it inside the method, pass it in as an argument to the method, or make sure it's otherwise visible inside the class. 您必须在方法内部声明它,将其作为方法的参数传递给它,或者确保它在类内部是可见的。

As others have commented though, you should probably show us more code for a more specific answer. 正如其他人所评论的那样,您可能应该向我们展示更多代码以获得更具体的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM