- Home /
Monodevelop Does not Access List or IEnumerator?
I'm trying to access IEnumerator and List<> in my code; and for some reasons both are giving errors for non-existence.
I'm using Windows 8 and Unity 4.3.4.
Is this any bug or do I have to call more classes to be able to access them?
Thanks.
Answer by emalb · Feb 17, 2014 at 01:44 PM
Google 'c# list' and follow the first link, which is almost always going to take you to a page on the Microsoft Developer Network. When you get there look for the namespace and you'll see it's System.Collections.Generic, so just add 'using System.Collections.Generic' at the top of your script, following the default 'using' statements that you'll find there.
Repeat for IEnumerator and you'll find it's in System.Collections, which is actually there by default. In this case, I think you should check your spelling of IEnumerator. I only say this because you have a typo in it in your question's title, so you may have the same one in your script too.
Oh, that's a pity. In that case, I would ask you to post some example code and we'll see if anyone can get us further.
@artofshashank If you're on Windows, you can use ALT-Space when you get that problem with the dialog appearing behind the splash screen. That bring up the dialog's window menu where you can cursor down to $$anonymous$$ove and then use the cursor keys to move the dialog box around (works on almost all windows.)
It doesn't solve your problem, of course! :)
Answer by Avi_Dwivedi · Feb 20, 2014 at 07:42 AM
I also faced this problem. make sure that you inherit MonoBehaviour in your class. without that LIst will not show in unity.
yep. All my scriptsright now are $$anonymous$$onobehaviour.
Answer by MattMorris · Feb 20, 2014 at 05:53 AM
http://www.dotnetperls.com/list < dotnetperls is a great C# reference.. they take you step by step and explain whats going on. I used this early on when the msdn docs were a bit to much to handle, but anyway here is a working example of a list to try and to compare to:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ListExample : MonoBehaviour {
List<int> myInts = new List<int>();
bool print = true;
// Use this for initialization
void Start () {
myInts.Add(1);
myInts.Add(99);
myInts.Add(208);
}
static IEnumerable<int> YieldReturn()
{
yield return 1;
yield return 2;
yield return 3;
}
// Update is called once per frame
void Update () {
if(print)
{
foreach(int myInt in myInts)
{
Debug.Log("my List values: " + myInt);
}
foreach (int i in YieldReturn())
{
Debug.Log("My IEnumerable values: " + i);
}
print = false;
}
}
}
http://stackoverflow.com/questions/3628425/ienumerable-vs-list-what-to-use-how-do-they-work < also another great reference for IEnumerable vs Lists
If you place the above code in a new scene on a game object you should see whats expected. list will print 1, 99, and 208. while ienuerable will print 1,2,3 GL!
$$anonymous$$att$$anonymous$$orris....as Whydoidoit said...your code won't do any good to me. List, IEnumerator, IEnumerable....these things are not even getting accessed.
I know how they work. But thanks for sharing this anyways.
Your answer

Follow this Question
Related Questions
A node in a childnode? 1 Answer
IEnumerator in Update 2 Answers
Everytime I alter code during runtime my lists break 0 Answers
Saving list of vector 3 using JSON 1 Answer
Monodevelop problem 1 Answer