我是编程新手,我正在寻找可以使用C#编程在文本文件中编写和添加值的源代码。代码应该要求用户在控制台窗口中输入值。价值观是: - 输入名称,输入帐号,输入余额
输出应按以下格式存储在文本文件中: -
Mark,10001,230000
Steve,10002,32987
Bruce,10003,23454
William,10004,23454
我将不胜感激。
答案 0 :(得分:1)
string name;
int number1,number2;
// Read name, number1, number2 from Console
//.....
//.....
//Saving in a file:
string outputFileName = @"c:\myfile.txt"
StreamWriter sw = new StreamWriter(outputFileName);
sw.WriteLine(string.Format("{0},{1},{2}",name,number1,number2));
sw.Close();