帮助用C#编写程序 [英] Help writing program in C#
本文介绍了帮助用C#编写程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何要求用户输入他们的姓名和地址,并让程序返回他们所说的内容?我还必须将名称和地址存储到文本文件中。
How do I ask for a user to input their name and address and have the program return what they say? I also have to store the name and address into a text file.
推荐答案
您好kaypro94,
Hi kaypro94,
感谢您在此发帖。
这是一个供您参考的简单示例。
Here is a simple example for your reference.
List<string> lines = new List<string>();
Console.WriteLine("Please input your name:");
string name = Console.ReadLine();
lines.Add(name);
Console.WriteLine("Please input your address");
string address = Console.ReadLine();
lines.Add(address);
Console.WriteLine("Thanks! Save it.");
File.WriteAllLines("file.txt", lines);
Console.ReadKey();
最诚挚的问候,
Wendy
这篇关于帮助用C#编写程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文