C# list type not working
I've been studying C# for the past couple of days and my book now tells me to add:" public List listname" but Microsoft Visual Studio and Unity report an error at "List" I have checked for spelling mistakes and have rewritten it a dozen times. The only explanation I could possibly think would be that something has changed since the book came out (it seems to be made for a much earlier version of Unity). This has been driving me crazy! Thanks in advance.
*add: "public List(lowerthansymbol)GameObject(greaterthansymbol) listname" *Report error at "List(lowerthansymbol)GameObject(greaterthansymbol)"
Answer by Rangr · Dec 05, 2015 at 07:29 AM
I have to ask the question, Have you included System.Collections.Generic; in your code? Lists are not included automatically so if you don't have the line "using System.Collections.Generic;" in your code it won't be usable. That stumped me for a while. If you have and are using the correct command (public List listName;), then things should be working correctly.
Your answer
Follow this Question
Related Questions
Insert string into empty list at a specific index 0 Answers
Is there anyway to make a list of prewritten variables? (C#) 2 Answers
How to get all children of a Gameobject with a certain component 2 Answers
I need help finding the index of an object in a list. 1 Answer
ArgumentOutOfRangeException: Argument is out of range. 1 Answer