joe_pool_is
Contributor
I'm writing a Roster class for our company's training program, and I'd like the class to implement the ICollection interface using our Employee class as a template:
When I punched this into VS2008, Intellisense gave me the options under ICollection to Implement Interface 'ICollection<Employee>' and Explicitly Implement Interface 'ICollection<Employee>'.
Poo-doo! The ICollection interface is something I've never gotten a chance to work with, so I don't really know what the difference is. I just picked the simpler looking one, Implement Interface 'ICollection<Employee>'.
VS constructed several of the required abstract class signitures (is there a term for that?) for me filled with the default "throw new NotImplementedException();" line in each routine, and I proceeded to fill these values using my private List<Employee> empList object.
Later, I noticed that Intellisense still gave me the option to Explicitly Implement Interface 'ICollection<Employee>'. Since I can't seem to find any articles either in my C# books or online that tell me what the differences are, I went ahead and picked that one too.
Now in my code, I've got what looks like duplicates:
Help!
Where can I find something that shows me how to implement all of these methods?
If a base class to implement from would help, here's what I have:
With this simple stub, could someone show me how to implement ICollection on the Roster class?
Thanks,
Joe
Visual Basic:
public class Roster : ICollection<Employee>
When I punched this into VS2008, Intellisense gave me the options under ICollection to Implement Interface 'ICollection<Employee>' and Explicitly Implement Interface 'ICollection<Employee>'.
Poo-doo! The ICollection interface is something I've never gotten a chance to work with, so I don't really know what the difference is. I just picked the simpler looking one, Implement Interface 'ICollection<Employee>'.
VS constructed several of the required abstract class signitures (is there a term for that?) for me filled with the default "throw new NotImplementedException();" line in each routine, and I proceeded to fill these values using my private List<Employee> empList object.
Later, I noticed that Intellisense still gave me the option to Explicitly Implement Interface 'ICollection<Employee>'. Since I can't seem to find any articles either in my C# books or online that tell me what the differences are, I went ahead and picked that one too.
Now in my code, I've got what looks like duplicates:
Visual Basic:
public void Add(Employee item)
{ // Implement interface 'ICollection<Employee>'
empList.Add(item);
}
// And now I have a new private member that I don't know
// what to do with below:
void ICollection<Employee>.Add(Employee item)
{ // Explicitly Implement interface 'ICollection<Employee>'
throw new NotImplementedException();
}
Where can I find something that shows me how to implement all of these methods?
If a base class to implement from would help, here's what I have:
Visual Basic:
[Serializable()]
public class Roster
{
List<Employee> empList;
public Roster()
{
empList = new List<Employee>();
}
}
[Serializable()]
public class Employee
{
public Employee()
{
IdNumber = 0;
}
public Employee(int idNumber)
{
IdNumber = idNumber;
}
// Number that links to the Employee's ID Number in the database
public int IdNumber { get; set; }
}
Thanks,
Joe