作者Cloud (抓不住...)
看板C_Sharp
标题[问题] template语法问题
时间Tue Feb 24 20:13:27 2009
下述是我学习C#的疑问
public class TreeNode<ItemType>
{
public ItemType m_Value; // member
public TreeNode(ItemType val){m_Value = val; } // Ctor
public void comapre(ItemType v )
{
if( m_Value > v ) // 编译错误,这里的值会无法比较,即使
// ItemType为int
{
// some operation
}
}
}
请问该如何实做?? 是否需要ICompariable ??
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.174.36.244
1F:→ SmartGoose:你都这麽说,试试看吧^^ 02/24 21:04