Is this the way to declare a collection?

Excuse my English, it's not my first language. I really tried to find this solution everywhere but I can't find this code anywhere. I'm a relative newbie so this has got to be simple.

Now, I had a very easy class to make that looks like this:

 public class Worker { private string _nameLastname; public string NameLastname { get { return _nameLastname; } set { _nameLastname = value; } } private double _salary; public double Salary { get { return _salary; } set { _salary = value; } } public Worker(string nameLastname, double salary) { this.NameLastname = nameLastname; this.Salary= salary; } } 


Now, my notes say that in order to be able to use the class over more workers, we have to declare a collection that looks like this in each form code after 'public partial class Form1 : Form' :

private Collection<Worker> _workers = new Collection<Worker>(); public Collection<Worker> Workers { get { return _workers; } set { _workers = value; } } 

Now, this shows me this error: Error 1 The type or namespace name 'Collection' could not be found (are you missing a using directive or an assembly reference?)

As soon as I try to declare a list by simply exchanging 'Collection' for 'List' in the above code, it works fine. What is wrong here?

I'm using Visual Studio 2010 and .NET >Framework 4 Client Profile. When I was trouble shooting I saw someone solved the problem by changing the framework and that didn't work for me

by purplelovely via /r/csharp

Leave a Reply