Good Morning Sir/Madam
Let us say that I created a class…
public class Subject
{
private string _code;
private string _description;
public string Code
{
get { return _code; }
set { _code = value; }
}
public string Description
{
get { return _description; }
set { _description = value; }
} // end property
public Subject()
{
//empty default
} // end method
public Subject(string Code, string Description)
{
this.Code = Code;
this.Description = Description;
} // end method
public override string ToString()
{
return _code + " : " + _description;
} // end method
}
Then I want to create a strongly typed collection used to store Subject objects but then I don't want to store duplicate objects with the :
public void Add(Subject subjectObj)
Please help me out..
VulpesPosted Apr 24, 2013, 5:43 AM
http://msdn.microsoft.com/en-us/library/7a03ybbb(v=vs.100).aspx
So, in this case, I'd use:
If you try to uncomment either of the lines in bold, then you will get a 'duplicate object' exception.
Incidentally, when you say duplicate object, I've taken it that you mean the same object and not just a different object which happens to have the same Code and Description properties.