1.24小時時間格式制定
- 按照2019-12-10-13-00-00格式輸出:string dtnow = string.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now); //24小時制
- 按照2019-12-10-01-00-00格式輸出:string dtnow = string.Format("{0:yyyy-MM-dd-hh-mm-ss}", DateTime.Now); //12小時制
2.指定長度,對齊字符
- 簡單輸出:Console.WriteLine(string.Format("檔案名:{0}"),filename);
- 輸出指定占位長度為3:Console.WriteLine(string.Format("年積日:{0,3}"),DOY);
- 輸出長度為5,保留兩位小數的浮點型:Console.WriteLine(string.Format("天 線 高:{0,5:F3}"),AntennaH);
3.其他相關對齊
- 參考:https://www.cnblogs.com/coolsundy/p/5863190.html
- DateTime 時間格式轉化:參考:https://www.cnblogs.com/lonelyxmas/p/11567920.htm
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/93268.html
標籤:C#
上一篇:C# DataTable to List<T> based on reflection.
下一篇:.net core Json字串的序列化和反序列化通用類原始碼,Newtonsoft和DataContractJsonSerializer性能對比
