How to get the year of a date in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        DateTime now = DateTime.Now;
        
        int y = now.Year;
        
        Console.WriteLine(y);
    }
}




/*
run:

2020

*/

 



answered Sep 12, 2020 by avibootz
...