I'm trying to write a class where I need to sort a list of TreeNode objects
in a certain way.
So I thought I'd use:
List<ListNodeData>
and then use the Sort method. I have the code working using SortedList
class, but its too slow since it sorts each time you insert. But just by
DECLARING the ListNodeData object, I get the infamous "exception has been
thrown by a target of an invocation" or whatever. I'm not even USING the
object and it throws an exception.
This is my ListNodeData class... it causes an exception by just being
defined in the namespace without even being used. Whats wrong with it?
public class ListNodeData : Object
{
public String strSortKey;
public TreeNode data;
public ListNodeData()
{
strSortKey = null;
data = null;
}
public override bool Equals(object obj)
{
if (obj.GetType() != this.GetType())
return false;
ListNodeData other = (ListNodeData)obj;
if ((other.strSortKey == strSortKey) && (other.data == data))
return true;
return false;
}
public override int GetHashCode()
{
return strSortKey.GetHashCode() ^ data.GetHashCode();
}
public override String ToString()
{
return data.ToString();
}
public ListNodeData Copy()
{
return (ListNodeData)MemberwiseClone();
}
}