CalculatorDotNet 0.1.0

dotnet add package CalculatorDotNet --version 0.1.0
                    
NuGet\Install-Package CalculatorDotNet -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CalculatorDotNet" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CalculatorDotNet" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CalculatorDotNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CalculatorDotNet --version 0.1.0
                    
#r "nuget: CalculatorDotNet, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CalculatorDotNet@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CalculatorDotNet&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CalculatorDotNet&version=0.1.0
                    
Install as a Cake Tool

CalculatorDotNet

CalculatorDotNet is a .NET binding of the Microsoft Calculator calculation engine (CalcManager).

Installing

dotnet add package CalculatorDotNet

Usage

using CalculatorDotNet;

using var calculator = new Calculator();

calculator.SendCommands(
    CalculatorCommand.One,
    CalculatorCommand.Add,
    CalculatorCommand.Two,
    CalculatorCommand.Equals);

Console.WriteLine(calculator.PrimaryDisplay); // "3"
// Scientific: sin(90°)
calculator.Mode = CalculatorMode.Scientific;
calculator.SendCommands(CalculatorCommand.Nine, CalculatorCommand.Zero, CalculatorCommand.Sine);

// Programmer: 255 in hex
calculator.Mode = CalculatorMode.Programmer;
calculator.SendCommands(CalculatorCommand.Two, CalculatorCommand.Five, CalculatorCommand.Five, CalculatorCommand.Equals);
calculator.SetRadix(NumberRadix.Hexadecimal); // PrimaryDisplay == "FF"

Unit conversion

using var converter = new UnitConverter(
[
    new UnitCategoryDefinition(1, "Length", SupportsNegative: false,
    [
        new UnitDefinition(10, "Meters", "m", Factor: 1.0, IsConversionTarget: true),
        new UnitDefinition(11, "Kilometers", "km", Factor: 1000.0, IsConversionSource: true),
    ]),
    new UnitCategoryDefinition(2, "Temperature", SupportsNegative: true,
    [
        new UnitDefinition(20, "Celsius", "°C", IsConversionSource: true),
        new UnitDefinition(21, "Fahrenheit", "°F", IsConversionTarget: true),
    ])
    {
        ExplicitConversions =
        [
            new ExplicitConversion(20, 21, Ratio: 1.8, Offset: 32.0),               // F = C * 1.8 + 32
            new ExplicitConversion(21, 20, Ratio: 1.0 / 1.8, Offset: -32.0, OffsetFirst: true),
        ],
    },
]);

converter.SendCommand(ConverterCommand.One); // 1 km ...
Console.WriteLine(converter.ToValue);        // "1000" (meters)

converter.SetCategory(2);
converter.SendCommands(ConverterCommand.One, ConverterCommand.Zero, ConverterCommand.Zero);
Console.WriteLine(converter.ToValue);        // "212" (°F)

Results surface through FromValue/ToValue, the DisplayChanged event, and SuggestedValues.

Building

git submodule update --init
dotnet build
dotnet test

iOS and Mac Catalyst apps

./build/apple/build-dylibs.sh
<ItemGroup>
  <ProjectReference Include="path/to/src/CalculatorDotNet/CalculatorDotNet.csproj" />
</ItemGroup>
<Import Project="path/to/build/apple/CalculatorDotNet.Apple.targets" />

License

The Microsoft Calculator sources are MIT licensed; see external/calculator/LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 130 9/2/2026