作者hasadent (路人x)
看板C_Sharp
标题Re: [请益] 简易Console输出入,换种写法
时间Thu Sep 1 09:06:23 2005
※ 引述《kingtw1978 (King)》之铭言:
: static void Main(string[] args)
: {
: Console.WriteLine("This is Assignment 2_1");
: Console.WriteLine("Please enter your name");
: string d;
: d = Console.ReadLine();
: Console.ReadLine();
: Console.WriteLine(" You entered " + (d) + " at " + DateTime.Now);
: }
: 这是我写的
: 前面两行是废话,再来是要你输入你的名字
: 利用 ReadLine() 把资料读出来,最後显示出来
: You entered [你的名字] at 时间
: 例如:You entered [John Smith] at 8/29/2005 11:32:45 AM
: 最重要的是後面那一行
: Console.WriteLine(" You entered " + (d) + " at " + DateTime.Now);
: 有办法稍微改变吗?或是别种写法
: 不然很容易和别人重复到.....谢谢
如果只是要看起来不一样
那用 string.Format 也可以
Console.WriteLine(
string.Format("You entered {0} at {1}", d, DateTime.Now)
);
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.131.34.68