4,107 questions
Probably your project is based on .NET Framework, not on .NET 5. Then you should create a new project. For example, try a new “Windows Forms App” (not “Windows Forms App (.NET Framework)”. Use this code:
int week1 = System.Globalization.ISOWeek.GetWeekOfYear( DateTime.Today );
// or:
int week2 = System.Globalization.ISOWeek.GetWeekOfYear( new DateTime( 2023, 3, 3 ) );
The using statements are grayed when not needed (not used). If you add using System.Globalization, then you can simplify the function: ISOWeek.GetWeekOfYear(...).