日期:2014-05-18  浏览次数:20472 次

帮忙翻译成c#
sub   create_tree(byval   menuData,as   Dataset,byval   menuFather_ID   as   Integer,byVal   FatherNode   as   TreeNode)
dim   filterStr   as   String
filterStr= "上级分类编号= "+cstr(menuFather_ID)
dim   subMenu()   as   DataRow
subMenu=menuData.tables(0).select(filterStr)
dim   i   as   integer
for   i=0   to   subMenu.GetUpperBound()
    dim   menuNode   as   TreeNode=new   TreeNode()
    menuNode.text=subMenu(i)(3).ToString
    if   menuFather_ID=0   then
        treeview1.nodes.add(menuNode)
    else
        FatherNode.ChildNodes.Add(menuNode)
    end   if
    create_tree(menuData,subMenu(i)(0),menuNode)
next

end   sub


------解决方案--------------------
string filterStr;
filterStr = "上级分类编号= " + System.Convert.ToString(menuFather_ID);
DataRow[] subMenu;
subMenu = menuData.tables(0).select(filterStr);
int i;
for (int i = 0; i <= subMenu.GetUpperBound(); i++) {
TreeNode menuNode = new TreeNode();
menuNode.text = subMenu(i)(3).ToString;
if (menuFather_ID == 0) {
treeview1.nodes.add(menuNode);
} else {
FatherNode.ChildNodes.Add(menuNode);
}
create_tree(menuData, subMenu(i)(0), menuNode);
}