- Home /
This post is currently awaiting moderation. If you believe this to be in error, contact a system administrator.
This question was
closed Nov 29, 2019 at 08:26 AM by
Hellium for the following reason:
Question is off-topic or not relevant. Not a question specific to Unity
Question by
Gabe-Tucker · Nov 29, 2019 at 05:26 AM ·
c#listliststable
Make Lists within a List
Hey! I want to make arraysNames and arraysData be lists of the previous lists. However, I get this error message: Using the generic type 'List' requires 1 type arguments. What should I do to fix it? Thanks in advance!
public string[] traitNames = { "Happiness", "Respect", "Authority" };
public float[] traitData = { 1, 1, 3 };
public string[] suppliesNames = { "Food", "Iron", "Gold" };
public float[] suppliesData = { 3, 2, 1 };
private List[] arraysNames = { traitNames, suppliesNames };
private List[] arraysData = { traitData, suppliesData };
Comment
List is a generic type. Use
List<string[]>
List<float[]>
You can also use List<List<sometype>> etc
https://www.tutorials$$anonymous$$cher.com/csharp/csharp-generics
Follow this Question
Related Questions
How to modify array values? 1 Answer
A node in a childnode? 1 Answer
How to initialize lists with set number of null elements? 1 Answer
Why the List in the class when using it is not the same in another class ? 1 Answer
How to compare a string in a list with a gameobject.name from another list of gameobjects 1 Answer