求C #代码注释
求C #代码注释namespace ADS_PC_Communication
{
public partial class Form1 : Form
{
private TwinCAT.Ads.TcAdsClient myAdsClient;
private System.Timers.Timer myTimer;
//private Boolean bActionFlag;
private Boolean bGreen, bRed, bYellow;
private Boolean bDemoLight;
private int iDimmer;
private Boolean bFlag;
private AdsStream dataStream;
private int iValue;
private Boolean bValue;
private BinaryReader binRead;
public Form1()
{
InitializeComponent();
}
private void xmlfun(){
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath + "/config.xml");
XmlElement node = doc.CreateElement("phone");
XmlAttribute atr = doc.CreateAttribute("id");
atr.InnerText = "003";
node.Attributes.Append(atr);
XmlNode xnode = (XmlNode)doc.CreateElement("Name");
xnode.InnerText = "testName";
node.AppendChild(xnode);
xnode = (XmlNode)doc.CreateElement("Number");
xnode.InnerText = "119";
node.AppendChild(xnode);
xnode = (XmlNode)doc.CreateElement("City");
xnode.InnerText="CS";
node.AppendChild(xnode);
xnode=(XmlNode)doc.CreateElement("DateOftBirth");
xnode.InnerText="12/02/1978";
node.AppendChild(xnode);
doc.DocumentElement.InsertAfter(node,doc.DocumentElement.LastChild);
doc.Save(Application.StartupPath + "/config1.xml");
}
--------------------编程问答-------------------- /*
namespace ADS_PC_Communication
{
public partial class Form1 : Form
{
private TwinCAT.Ads.TcAdsClient myAdsClient;
private System.Timers.Timer myTimer;
//private Boolean bActionFlag;
private Boolean bGreen, bRed, bYellow;
private Boolean bDemoLight;
private int iDimmer;
private Boolean bFlag;
private AdsStream dataStream;
private int iValue;
private Boolean bValue;
private BinaryReader binRead;
public Form1()
{
InitializeComponent();
}
private void xmlfun(){
XmlDocument doc = new XmlDocument();
doc.Load(Application.StartupPath + "/config.xml");
XmlElement node = doc.CreateElement("phone");
XmlAttribute atr = doc.CreateAttribute("id");
atr.InnerText = "003";
node.Attributes.Append(atr);
XmlNode xnode = (XmlNode)doc.CreateElement("Name");
xnode.InnerText = "testName";
node.AppendChild(xnode);
xnode = (XmlNode)doc.CreateElement("Number");
xnode.InnerText = "119";
node.AppendChild(xnode);
xnode = (XmlNode)doc.CreateElement("City");
xnode.InnerText="CS";
node.AppendChild(xnode);
xnode=(XmlNode)doc.CreateElement("DateOftBirth");
xnode.InnerText="12/02/1978";
node.AppendChild(xnode);
doc.DocumentElement.InsertAfter(node,doc.DocumentElement.LastChild);
doc.Save(Application.StartupPath + "/config1.xml");
} */ --------------------编程问答-------------------- ctrl + E u --------------------编程问答-------------------- up --------------------编程问答-------------------- namespace ADS_PC_Communication
{
public partial class Form1 : Form
{
private TwinCAT.Ads.TcAdsClient myAdsClient;
private System.Timers.Timer myTimer;
//private Boolean bActionFlag;
private Boolean bGreen, bRed, bYellow;
private Boolean bDemoLight;
private int iDimmer;
private Boolean bFlag;
private AdsStream dataStream;
private int iValue;
private Boolean bValue;
private BinaryReader binRead;
public Form1()
{
InitializeComponent(); //初始化组件,事件等。
}
private void xmlfun(){
XmlDocument doc = new XmlDocument(); //创建xmlDocument
doc.Load(Application.StartupPath + "/config.xml"); //把xml文件load到xmlDocument中
XmlElement node = doc.CreateElement("phone"); //创建xml节点
XmlAttribute atr = doc.CreateAttribute("id"); //创建xml属性
atr.InnerText = "003"; //属性赋值
node.Attributes.Append(atr); //属性放在节点上
XmlNode xnode = (XmlNode)doc.CreateElement("Name");
xnode.InnerText = "testName";
node.AppendChild(xnode);
xnode = (XmlNode)doc.CreateElement("Number");
xnode.InnerText = "119";
node.AppendChild(xnode);
xnode = (XmlNode)doc.CreateElement("City");
xnode.InnerText="CS";
node.AppendChild(xnode);
xnode=(XmlNode)doc.CreateElement("DateOftBirth");
xnode.InnerText="12/02/1978";
node.AppendChild(xnode);
doc.DocumentElement.InsertAfter(node,doc.DocumentElement.LastChild);//节点插入到document最后
doc.Save(Application.StartupPath + "/config1.xml");//保存文件到硬盘。
}
--------------------编程问答-------------------- /*代码*/
//代码 --------------------编程问答--------------------
private void xmlfun()--------------------编程问答-------------------- 如楼上所写,其实你可以每句每句在网上搜索 --------------------编程问答-------------------- //
{
//创建dom对像
XmlDocument doc = new XmlDocument();
//加载xml文件
doc.Load(Application.StartupPath + "/config.xml");
//增加phone根节点
XmlElement node = doc.CreateElement("phone");
//id属性
XmlAttribute atr = doc.CreateAttribute("id");
//id属性值
atr.InnerText = "003";
//为phone增加id属性
node.Attributes.Append(atr);
//结果:<phone id="003"></phone>
//增加name节点
XmlNode xnode = (XmlNode)doc.CreateElement("Name");
//节点内容
xnode.InnerText = "testName";
//增加到phone节点下边
node.AppendChild(xnode);
//如上
xnode = (XmlNode)doc.CreateElement("Number");
xnode.InnerText = "119";
node.AppendChild(xnode);
//如上
xnode = (XmlNode)doc.CreateElement("City");
xnode.InnerText = "CS";
node.AppendChild(xnode);
xnode = (XmlNode)doc.CreateElement("DateOftBirth");
xnode.InnerText = "12/02/1978";
node.AppendChild(xnode);
//插入到文件的最后
doc.DocumentElement.InsertAfter(node, doc.DocumentElement.LastChild);
//保存文档
doc.Save(Application.StartupPath + "/config1.xml");
}
/// <summary>
///
/// </summary>
http://www.cnblogs.com/wj110reg/articles/845944.html
补充:.NET技术 , C#