我想知道我怎样才能走过这个循环?这有一个根两个 chldren priv 和 nonpriv 以及它们的孩子 priv:0,1,2,...,1023 和 Nonpriv 的孩子:1024,..,65535
|Any______________PORT|
| |
|Priv| |Non-Priv|
|||||...|||| ||||....|||||
0123,.....1023 1024,...65535
我的意思是 0 在不同的节点中 1 在不同的节点中 2 在不同的节点中 这些端口有父 PRIV 我区分它们的原因是也许有一天 0 会有
他们可能在列表中的子列表和我们可以有一个节点列表,或者它们可以在一个字符串列表中,但是我无法决定接下来要对字符串列表做什么,并且节点列表的问题在于我无法构建节点的 for 循环
现在我无法配置 for 循环我应该如何更正我的代码?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IDS
{
class Program
{
static void Main(string[] args)
{
Node root = new Node("Any_PORT");
List<Node> portcat = new List<Node>();
Node Priv = new Node("Priv");
Node NonPriv=new Node("Non-Priv");
root.setchildren(portcat);
root.Thisisroot();
root.setNodeinlist(Priv);
root.setNodeinlist(NonPriv);
Priv.setparent(root);
NonPriv.setparent(root);
List<Node> portsP = new List<Node>();
Priv.setchildren(portsP);
for (int i = 0; i < 1024; i++)
{
}
//I tried this one but I can't fix between Nodes and list of a string
List<string> portsN = new List<string>();
for (int i = 1024; i < 65535; i++)
{
portsN.Add(i.ToString());
}
}
public class Node
{
public string Data;
public List<Node> Children = new List<Node>();
public Node parent;
public Node(string r)
{
this.Data = r;
}
public Node Thisisroot()
{
this.parent = null;
return this;
}
public void setchildren(List<Node> list)
{
this.Children = list;
}
public List<Node> getchildren()
{
return this.Children;
}
public void setparent(Node p)
{
this.parent = p;
}
public Node getparent()
{
return this.parent;
}
public void setNodeinlist(Node n)
{
this.Children.Add(n);
}
}
}
}