配置phpmyadmin連線遠端 MySQL資料庫
阿新 • • 發佈:2021-01-20
格式化
字串格式化
Console.WriteLine(string.Format("金額顯示:{0:C}", 368));
Console.WriteLine(string.Format("科學計數法顯示:{0:E}", 12000000.1));
Console.WriteLine(string.Format("分割數字顯示:{0:N0}", 123456789));
Console.WriteLine(string .Format("Π取兩位小數顯示:{0:F2}", Math.PI));
Console.WriteLine(string.Format("16進位制顯示:{0:X4}", 33));
Console.WriteLine(string.Format("百分比顯示:{0:P}", 0.96));
日期格式化
DateTime strDate = DateTime.Now;
Console.WriteLine(string.Format("短日期格式:{0:d}" , strDate));
Console.WriteLine(string.Format("長日期格式:{0:D}", strDate));
Console.WriteLine(string.Format("完整日期格式:{0:f}", strDate));
Console.WriteLine(string.Format("短時間格式:{0:t}", strDate));
Console.WriteLine(string.Format("長時間格式:{0:T}" , strDate));
Console.WriteLine(string.Format("月日期格式:{0:M}", strDate));
Console.WriteLine(string.Format("年月期格式:{0:Y}", strDate));
方法二:
int money = 1298;
Console.WriteLine(money.ToString("C"));
DateTime strDate = DateTime.Now;
Console.WriteLine(strDate.ToString("f"));