<分区>
我想分开这个:
0, 250, 6, 5000, 10000, 15000, 20000, 25000, 70, 70, 70, 70, 70, 70, 0,
我试过:
words = poly[a].Split(charseparators);
foreach (string word in words)
{
richTextBox1.Text += (d + 1)+ " " + word+ "\r\n";
d++;
}
这不是完整的代码,但问题是:它应该是这样的:
18 70
19 70
20 0
但它看起来像这样:
18 70
19 70
20 0
21
还有一个额外的部分,因为在最后一个词的末尾,总是有一个',' 我怎样才能删除最后一行?
代码:
public void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
int size = -1;
string text = "";
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
file = openFileDialog1.FileName;
try
{
text = File.ReadAllText(file);
size = text.Length;
}
catch (IOException)
{
}
}
int a = 0;
int b =1;
int c = 0;
int d = 0;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(file);
XmlNodeList nodes = xmlDoc.SelectNodes("//Pacs_Parad//Pac_Parameter_Set//Pac_Zuo_Pave_Para");
XmlNodeList polygon = xmlDoc.GetElementsByTagName("Polygon_CS_List");
XmlNodeList value = xmlDoc.GetElementsByTagName("Value");
XmlNodeList synonym = xmlDoc.GetElementsByTagName("Synonym_Name");
XmlNodeList typeflag = xmlDoc.GetElementsByTagName("Type_Flag");
string[] poly = new string[polygon.Count];
foreach(XmlNode node in polygon)
{
poly[a] = node.InnerText;
a++;
}
a = 0;
string[] tf = new string[size];
foreach (XmlNode node in typeflag)
{
tf[a] = node.InnerText;
a++;
}
a = 0;
richTextBox1.Multiline = true;
richTextBox1.Clear();
string[]words = null;
char[] charseparators = new char[] { ',' };
for (int i = 0; i <synonym.Count; i++)
{
richTextBox1.Text += b + "." + " Name: " + synonym[i].InnerText + "\r\n" +
" Type: " ;
if (tf[i] == "P")
{
richTextBox1.Text += "Polygon " + "\r\n";
words = poly[a].Split(charseparators);
foreach (string word in words)
{
richTextBox1.Text += (d + 1)+ " " + word+ "\r\n";
d++;
}
d = 0;
a++;
}
else
{
if (tf[i] == "C")
{
richTextBox1.Text += "Constant " + "\r\n";
richTextBox1.Text += "value: " + value[c].InnerText + "\r\n";
c++;
}
}
richTextBox1.Text += "\r\n";
b++;
}
}