# Generic Collection\<t\>

**URL:** <https://forum.kirupa.com/t/generic-collection-t/263646>\
**Category:** programming\
**Created:** [June 17, 2008, 10:53pm UTC](https://forum.kirupa.com/t/generic-collection-t/263646 "2008-06-17T22:53:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gigahertz205](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@gigahertz205](https://forum.kirupa.com/u/gigahertz205)\
**Post date:** [June 17, 2008, 10:53pm UTC](https://forum.kirupa.com/t/generic-collection-t/263646/1 "2008-06-17T22:53:58Z")

</div>

I am trying to compile a code using Collection, but Visual Express C# 2008 says that “type or namespace name ‘Collection’ could not be found.”

I am new to generics so I dont know what Im doing wrong.

```auto
Collection<[COLOR=blue]string[/COLOR]> people = [COLOR=blue]new[/COLOR] Collection<[COLOR=blue]string[/COLOR]>();

```

That is the line that the compiler has trouble with.

---

<div class="post-metadata">

**Author:** ![Raydred](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/raydred/32/65_2.png) [@Raydred](https://forum.kirupa.com/u/Raydred)\
**Post date:** [June 17, 2008, 11:55pm UTC](https://forum.kirupa.com/t/generic-collection-t/263646/2 "2008-06-17T23:55:31Z")

</div>

Im not 100% sure, (because I too am learning), but I dont think “Collection” is a valid class, let alone a valid generic class (Unless you wrote a class called Collection). Make sure you have the “System.Collections.Generic” reference, and you could use something like “List\<\>”…

```auto
List<[COLOR="Blue"]string[/COLOR]> people = new List<[COLOR="blue"]string[/COLOR]>();

```

Hope that helps.

---

<div class="post-metadata">

**Author:** ![Templarian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/templarian/32/7152_2.png) [@Templarian](https://forum.kirupa.com/u/Templarian)\
**Post date:** [June 18, 2008, 12:21am UTC](https://forum.kirupa.com/t/generic-collection-t/263646/3 "2008-06-18T00:21:35Z")

</div>

^Learning is fun :fab:

You forgot the namespace.

```auto
using System.Collections.ObjectModel;

```

---

<div class="post-metadata">

**Author:** ![gigahertz205](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@gigahertz205](https://forum.kirupa.com/u/gigahertz205)\
**Post date:** [June 18, 2008, 1:37am UTC](https://forum.kirupa.com/t/generic-collection-t/263646/4 "2008-06-18T01:37:21Z")

</div>

Ah yes. Thank you. I thought I was supposed to add the System.Collections reference, but such thing did not exist. 🙂

---

<div class="post-metadata">

**Author:** ![Templarian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/templarian/32/7152_2.png) [@Templarian](https://forum.kirupa.com/u/Templarian)\
**Post date:** [June 18, 2008, 1:50am UTC](https://forum.kirupa.com/t/generic-collection-t/263646/5 "2008-06-18T01:50:13Z")

</div>

You should always have the

Using System.Collections;

But you would then add the other one below it.

using System.Collections;  
using System.Collections.ObjectModel;

---

<div class="post-metadata">

**Author:** ![Raydred](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/raydred/32/65_2.png) [@Raydred](https://forum.kirupa.com/u/Raydred)\
**Post date:** [June 19, 2008, 4:38am UTC](https://forum.kirupa.com/t/generic-collection-t/263646/6 "2008-06-19T04:38:07Z")

</div>

yay, i learned something as well! =)

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [June 19, 2008, 4:51am UTC](https://forum.kirupa.com/t/generic-collection-t/263646/7 "2008-06-19T04:51:02Z")

</div>

If you right-click on Collection, there should be a menu-item called Resolve that will take care of this for you automatically (unless the actual reference itself isn’t there) 🙂

---

<div class="post-metadata">

**Author:** ![Charleh](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@Charleh](https://forum.kirupa.com/u/Charleh)\
**Post date:** [June 19, 2008, 1:02pm UTC](https://forum.kirupa.com/t/generic-collection-t/263646/8 "2008-06-19T13:02:15Z")

</div>

Yeah usually it pops up with a squiggly line under the error and will pop up a suggestion box when you hover on this squiggly line usually giving you the namespaces with the most similar sounding items in with the one you want at the top.

Of course if it already knows what you are talking about why does it need the imports statement :D?!?!?!

---

<div class="post-metadata">

**Author:** ![Templarian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/templarian/32/7152_2.png) [@Templarian](https://forum.kirupa.com/u/Templarian)\
**Post date:** [June 19, 2008, 2:10pm UTC](https://forum.kirupa.com/t/generic-collection-t/263646/9 "2008-06-19T14:10:04Z")

</div>

^I believe only [vb.net](http://vb.net) does this.

---

<div class="post-metadata">

**Author:** ![Charleh](https://avatars.discourse-cdn.com/v4/letter/c/a9a28c/32.png) [@Charleh](https://forum.kirupa.com/u/Charleh)\
**Post date:** [June 19, 2008, 2:20pm UTC](https://forum.kirupa.com/t/generic-collection-t/263646/10 "2008-06-19T14:20:31Z")

</div>

Oh, fair enough 😛 I program in .NET at work because noone knows C/C++ and they don’t really want the headache of learning a new syntax so I’ve not really used c#

Of course I do accidentally add braces and semicolons to the end of my .NET code sometimes 😃
