Multiple choice technology web technology

How to get last month date from C# code?

  1. DateTime.Now.PreviousMonth;

  2. DateTime.Now.CurrentMonth - 1;

  3. DateTime.Now.AddMonths(-1);

  4. DateTime.Now.AddMonths(1);

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The AddMonths method is the correct way to perform date arithmetic in C#. Using a negative parameter (-1) subtracts months from the current date. DateTime.Now.AddMonths(1) would give next month, and there are no PreviousMonth or CurrentMonth properties on DateTime.