Re: [請益] 簡易Console輸出入,換種寫法
※ 引述《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
討論串 (同標題文章)