0

Am I missing some reference?

List<Item> _items = new List<Item>();

The type or namespace name 'Item' could not be found (are you missing a using directive or an assembly reference?)

I'm new to using Lists and Delegates and stuff...

tshepang
  • 12,111
  • 21
  • 91
  • 136
Adam
  • 612
  • 4
  • 13
  • 23
  • 5
    Yes, you are missing a reference to `Item`, as it says right there. – Artless Aug 14 '13 at 13:14
  • I have you declared your Item class? It is List and T needs to be declared. – CodeBeard Aug 14 '13 at 13:15
  • .. Do you have a class named Item in your code? – Pierre-Luc Pineault Aug 14 '13 at 13:15
  • I think you're missing a using directive or an assembly reference..., this mean Item is in another project or namespace and you don't have the using reference to it. if you right click on it in visual studio there is the option to add the using statement, if it doesn't apper you have to add a reference to the library that contain the class Item – Fabio Marcolini Aug 14 '13 at 13:15
  • 3
    right Click on `Item` and see if you get `Resolve` in the menu, click that – Habib Aug 14 '13 at 13:16
  • What is `Item`, have you made a class somewhere in your application. – Colin Steel Aug 14 '13 at 13:16
  • Also, if you do indeed have an Item class, make sure it's public if you're trying to use it : ) – Kestami Aug 14 '13 at 13:17
  • @Shane.C Although what you say is true, if that were the problem wouldn't the error say `The class 'Item' is not accessible due to its protection level`? – Nolonar Aug 14 '13 at 13:19
  • Oh.. I thought Item is something already defined like Object, etc... Thanks, everyone – Adam Aug 14 '13 at 13:21
  • @Nolonar You're right :) My bad. – Kestami Aug 14 '13 at 13:24
  • @Adam Issues are "solved" when an answer is accepted. Don't just add "Solved" to the title. – Nolonar Aug 14 '13 at 13:31
  • @Nolonar Yeah I know, but it wouldn't let me accept an answer for another 7 minutes, and after that I just forgot. I just remembered though, so there we go. – Adam Aug 16 '13 at 01:31

1 Answers1

2

If Item is a type that exists in your code / references, right click on it, open the "resolve" menu, and select the "using xx" option to add the correct namespace reference. Also, if Item is a type you're created, ensure it is visible to this class (might need to be scoped as public, if it isn't).

If Item doesn't exist - create it, add a reference to the dll containing it, or replace it with something that exists :)

Deeko
  • 1,514
  • 9
  • 29