How to get the month name in C#?

前端 未结 6 2042
深忆病人
深忆病人 2020-12-04 18:41

How does one go about finding the month name in C#? I don\'t want to write a huge switch statement or if statement on the month int. I

6条回答
  •  一整个雨季
    2020-12-04 19:23

    Supposing your date is today. Hope this helps you.

    DateTime dt = DateTime.Today;
    
    string thisMonth= dt.ToString("MMMM");
    
    Console.WriteLine(thisMonth);
    

提交回复
热议问题