PDA

View Full Version : سوال: اشکال در برنامه ی درخت



soroush68
شنبه 15 فروردین 1388, 06:03 صبح
http://soroushweb.persiangig.com/BinaryTree.zip

در برنامه ی ساده ی بالا با ارور زیر مواجه میشم

Error 1 'BinaryTree.Tree<TItem>' does not contain a definition for 'CompareTo' and no extension method 'CompareTo' accepting a first argument of type 'BinaryTree.Tree<TItem>' could be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Mahdi Jafari\My Documents\Visual Studio 2008\Projects\BinaryTree\BinaryTree\Tree.cs 23 22 BinaryTree

ممنون

soroush68
یک شنبه 16 فروردین 1388, 05:09 صبح
در فروم ام اس ان مایکروسافت اینطور مساله حل شد
public int CompareTo(object obj)
{
if (obj is TItem)
{
TItem temp = (TItem)obj;
return NodeData.CompareTo(temp);
}
throw new ArgumentException("object is not TItem");
}
اون متد اینطور باید تعریف میشد