どうすればこのループを通り抜けることができますか?これには、ルート2つのchldren privとnonprivがあり、priv:0,1,2、...、1023の子とNonprivの子:1024、..、65535があります。
|Any______________PORT|
| |
|Priv| |Non-Priv|
|||||...|||| ||||....|||||
0123,.....1023 1024,...65535
つまり、0は別のノードにあります1は別のノードにあります2は別のノードにありますこれらのポートには親PRIVがあり
ますノードのリストを作成することも、文字列のリストに含めることもできますが、文字列のリストについて次に何をするかを決めることができず、ノードのリストの問題は、ノードを構築できなかった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);
}
}
}
}