スペースの入力

String型変数 月にDateTime.Now.Date.Month.ToString()を代入しました。
出てきた数字(今月なら5)の前に半角スペースをつけたい(2023年 5月のように)です。どのように記述したら良いでしょうか?よろしくお願いいたします。

こんにちは

以下お試しください

C#

 DateTime.Now.Month.ToString().PadLeft(2,' ')

VB

DateTime.Now.Month.ToString().PadLeft(2," "c)

解決いたしました!ありがとうございました。

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.