逐个打印值

时间:2014-04-15 08:24:57

标签: c#

我创建简单的获取值并在打印语句中打印它没有空间的值,我希望它会逐个来......

string s, n;
Console.WriteLine("Enter your name");
s = Console.ReadLine();
Console.WriteLine("Enter your address");
n = Console.ReadLine();
Console.WriteLine("Enter your phonenumber");
int m = int.Parse(Console.ReadLine());
Console.WriteLine("Enter your Dob");
int p = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter your name:" + s + "Enter your address:" + n +         "Enter your phone number:" + m + "Enter your dob:" + p);
Console.ReadLine();

5 个答案:

答案 0 :(得分:2)

使用Console.Writeline();来换行  或者使用可以使用转义字符\n

 Console.WriteLine("Enter your name\n");

或者您可以使用Environment.NewLine

答案 1 :(得分:1)

\和将转到新线

Console.WriteLine(" Enter your name \n");

答案 2 :(得分:1)

更改以下代码..

Console.WriteLine("\n Enter your name:" + s + "\nEnter your address:" + n + "\nEnter your phone number:" + m + "\nEnter your dob:" + p);

答案 3 :(得分:1)

Console.WriteLine("Enter your name:" + s + "\nEnter your address:" + n +"\nEnter your phone number:" + m + "\nEnter your dob:" + p);

答案 4 :(得分:1)

Console.WriteLine(Environment.NewLine + "Enter your name:" + s + Environment.NewLine + "Enter your address:" + n + Environment.NewLine + "Enter your phone number:" + m + Environment.NewLine + "Enter your dob:" + p);