我正在尝试写入 .xml 文件。问题是,当我写作时,我收到错误消息:Cannot convert from 'int' to 'string'。现在我知道这意味着我需要将整数转换为字符串,但我对如何做到这一点感到困惑。我正在使用的代码如下:
private void GetProperties()
{
//CreateNode(everything being referenced. Put text boxes, and drop down boxes here.
XmlTextWriter writer = new XmlTextWriter(@"C:\ForteSenderv2.0\Forte.dat", System.Text.Encoding.UTF8);
writer.WriteStartDocument(true);
//Making the code indeted by 2 characters.
writer.Formatting = Formatting.Indented;
writer.Indentation = 2;
//Making the start element "Table".
writer.WriteStartElement("Forte_Data_Gatherer_Application");
//Calling the rst of the .xml file to write.
CreateNode(Portbx.SelectedIndex, BaudRatebx.SelectedIndex, Databitsbx.SelectedIndex, Paritybx.SelectedIndex, StopBitsbx.SelectedIndex, Handshakingbx.SelectedIndex, writer);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
}
错误正在触发CreateNode(Portbx.SelectedIndex, BaudRatebx.SelectedIndex, Databitsbx.SelectedIndex, Paritybx.SelectedIndex, StopBitsbx.SelectedIndex, Handshakingbx.SelectedIndex, writer);