# Lists (C#)

**URL:** https://discussions.unity.com/t/lists-c/46716
**Category:** Questions & Answers
**Created:** [July 13, 2012, 10:46pm UTC](https://discussions.unity.com/t/lists-c/46716 "2012-07-13T22:46:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![DayyanSisson](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/dayyansisson/32/333585_2.png) [@DayyanSisson](https://discussions.unity.com/u/DayyanSisson)
#### Post date: [July 13, 2012, 10:46pm UTC](https://discussions.unity.com/t/lists-c/46716/1 "2012-07-13T22:46:15Z")

</div>

I’ve been trying to create a list, and even when I just copy/paste the variable declaration from someone’s code here on the Answers or the forums I get this error:

**The type or namespace name ‘List 1’ Could not be found. Are you missing an assembly reference or directive?**

Which doesn’t make sense because people used the exact same code I did and didn’t get this error. What am I doing wrong here?

```
public List<Transform> myList = new List<Transform>();

```

---

<div class="post-metadata">

### Author: ![Bunny83](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@Bunny83](https://discussions.unity.com/u/Bunny83)
#### Post date: [July 13, 2012, 10:53pm UTC](https://discussions.unity.com/t/lists-c/46716/2 "2012-07-13T22:53:18Z")

</div>

Just add:

```
using System.Collections.Generic;

```

at the top. See the [MSDN docs](http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx) for more information.

_ **edit** _  
alternatively you could always use the full classname, however that looks a bit strange:

```
public System.Collections.Generic.List<Transform> myList = new System.Collections.Generic.List<Transform>();

```

That’s why the using directive has been invented.

_ **edit** _  
Just in case a UnityScript user comes across, in UnityScript (Unity’s Javascript) you have to use the “import” keyword instead:

```
import System.Collections.Generic;

```

---

<div class="post-metadata">

### Author: ![nivabeath](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@nivabeath](https://discussions.unity.com/u/nivabeath)
#### Post date: [March 25, 2014, 7:01am UTC](https://discussions.unity.com/t/lists-c/46716/3 "2014-03-25T07:01:50Z")

</div>

List iList = new List();  
iList.Add(2);  
iList.Add(3);  
iList.Add(5);

C# List examples … [C# List](http://csharp.net-informations.com/collection/list.htm)
