In C#, you can use the DateTime class to get the current date, year, and days in a month. Here is some sample code that demonstrates how to do this:
//To get current year
int CurrentYear = DateTime.Now.Year;
// to get current month
int CurrentMonth = DateTime.Now.Month;
// to get days in current month
int days = DateTime.DaysInMonth(CurrentYear, CurrentMonth);
// to get next 1 year from current year
int NextYear= DateTime.Now.AddYears(1).Year;
// previous year
int PreYear = DateTime.Now.AddYears(-1).Year;
//Get current month name
DateTime dt = DateTime.Now.AddMonths(0);
string CurMonthName = dt.ToString("MMM").ToUpper();
You can also use the DateTime.Today
property which returns the current date but with the time part set to 00:00:00.
Alternatively, you can use the DateTime.UtcNow
property, which returns the current date and time in Coordinated Universal Time (UTC) format.
For more detailed information, you can check the official documentation of C# DateTime class.