Do I have .net 5.0 installed?

Hattie 20 Reputation points
2023-03-18T17:12:07.2866667+00:00
i'm confused

windows 10, fully updated
visual studio 2022  (64-bit) V17.5.1 fully updated (just installed)

Do I have .net 5.0 installed?

the registery states v4.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Net Framework Setup\NDP\CDF\v4.0
SMSvcHostPath    REG_SZ    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\


if i run the dotnet command from the DOS command line it states i have v7 sdk.

C:\Users\hattie>dotnet --list-sdks
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
7.0.201 [C:\Program Files\dotnet\sdk]

what do i have do i need to update somehow?

the problem is.....

I am learnig c# using visual studio

The c# command isoweek needs .net 5 work?

I think i have v7 installed.... maybe not

i am trying to get the isoweek number using c# in VS (Windows Form).

so will v7 sdk work? I assume the v7 sdk was installed with the VS installation so i am assuming the isoweek command would work.

i don't seem to be able to get windows to update itself to .net 5 I found the vy sdk web page

in my c# code -
the     using System.Globalization; 

statement at the top of my VS windows Form is greyed out suggesting to me that it's not included/working/recognised!!!!
so i must still be on .net v4

the c# command in my code

System.Globalization.ISOWeek.GetWeekOfYear("18-03-2023");

has a lot of red lines under it suggesting it's not recognised.

but i have v7 sdk .net???

where do i go from here?


also
as an aside

if I have the statement 
using System.Globalization; 

at the top of my code do i need to use the command - 

System.Globalization.ISOWeek.GetWeekOfYear("03-03-2023");

or can i simplyfiy it to 

ISOWeek.GetWeekOfYear("03-03-2023"); 

I assume i can !!!!

thank you
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,649 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,888 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 114.7K Reputation points
    2023-03-18T18:52:49.3366667+00:00

    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(...).

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful