There is a C# example code in examples/call_highs_from_csharp.cs
. From the HiGHS root directory, run
cmake -S. -Bbuild -DCSHARP=ON
If a CSharp compiler is available, this builds the example using cmake and generates a binary in the build directory (build/bin/csharpexample
).
The nuget package Highs.Native is on https://www.nuget.org, at https://www.nuget.org/packages/Highs.Native/.
It can be added to your C# project with dotnet
dotnet add package Highs.Native --version 1.9.0
The nuget package contains runtime libraries for
win-x64
win-x32
linux-x64
linux-arm64
macos-x64
macos-arm64
Details for building locally can be found in nuget/README.md
.
The C# API can be called directly. Here are observations on calling the HiGHS C# API from C#:
HiGHS/src/interfaces/highs_csharp_api.cs
contains all the PInvoke you need. highs.dll
, libhighs.dll
,
libhighs.so
, ... depending on your platform) can be found at runtime. How
to do this is platform dependent, copying it next to your C# executable
should work in most cases. You can use msbuild for that. On linux, installing
HiGHS system wide should work.Visual C++
make sure that the
MSVCRuntime
is installed on the machine you want to run your application
on.highs_csharp_api.cs
and have fun with HiGHS.This is the normal way to call plain old C from C# with the great simplification that you don't have to write the PInvoke declarations yourself.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.