Rafał Nowosielski Rafał Nowosielski - 3 years ago 143
C# Question

How to use Parse() method from the UnitsNet nuget package

I wanted to use UnitsNet in my C# project and saw in the documentation that the authors are using their classes to parse units of measure from string like this:

var usEnglish = new CultureInfo("en-US");
Mass kg = Mass.Parse(usEnglish, "1.0 kg");

I wanted to use it the same way, so I installed the package in my project using nuget console by invoking:

Install-Package UnitsNet

and made sure that the reference is added in the project.

The problem is that I still can't see the Parse()/TryParse() methods on any of the unit types.

Am I doing something wrong, or is the documentation outdated?

Answer Source

It turned out that the UnitsNet documentation was a little bit ahead of the time.

The version I have been pulling from NuGet with

Install-Package UnitsNet

was 3.4.0, and the changes I was trying to use, mentioned in the question were first introduced in version 3.5.0.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download