We've built simple demo applications that demonstrate how the LaunchDarkly client-side .NET SDK works. There are two demos:
- Console app (
DotNetConsoleApp): A .NET console application. - MAUI app (
MauiApp): A .NET MAUI application targeting Android and iOS.
Below, you'll find the build procedures. For more comprehensive instructions, you can visit your Quickstart page or the client-side .NET SDK reference guide.
These demos require .NET 8.0 or higher.
-
Set the value of the
mobileKeyvariable inDotNetConsoleApp/Program.csto your mobile key:const string mobileKey = "my-mobile-key";
Alternatively, set the
LAUNCHDARKLY_MOBILE_KEYenvironment variable:export LAUNCHDARKLY_MOBILE_KEY="my-mobile-key"
-
If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, set
flagKeyto the flag key:const string flagKey = "my-flag-key";
Otherwise,
sample-featurewill be used by default. -
On the command line, run:
dotnet run --project DotNetConsoleApp
You should receive the message:
"The sample-feature feature flag evaluates to false."
The application will run continuously and react to the flag changes in LaunchDarkly.
The MAUI app demonstrates LaunchDarkly in a mobile context using .NET MAUI, targeting both Android and iOS from a single project.
-
Install the MAUI workload if you haven't already:
dotnet workload install maui
-
Copy the example settings file and set your mobile key:
cp MauiApp/Resources/Raw/appsettings.example.json MauiApp/Resources/Raw/appsettings.json
Then edit
MauiApp/Resources/Raw/appsettings.jsonand set your mobile key:{ "MobileKey": "my-mobile-key", "FlagKey": "sample-feature" }The
appsettings.jsonfile is gitignored to prevent committing your key. -
Build and run:
- Android (deploy to a connected device or emulator):
dotnet build MauiApp -f net8.0-android -t:Run
- iOS (requires macOS with Xcode; deploy to a simulator):
dotnet build MauiApp -f net8.0-ios -t:Run
- Android (deploy to a connected device or emulator):
The app displays the current value of the feature flag. The background color changes from dark (#373841) to green (#00844B) when the flag evaluates to true. The app reacts to flag changes in real time.