A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/9.0/empty-env-variable below:

Breaking change: Support for empty environment variables - .NET

Support for empty environment variables

In this article

Support was added to be able to set an environment variable to the empty string using Environment.SetEnvironmentVariable(String, String). As part of this work, the behavior of setting the ProcessStartInfo.Environment and ProcessStartInfo.EnvironmentVariables properties was changed to be consistent with that of Environment.SetEnvironmentVariable(String, String).

Previous behavior

Previously:

New behavior

Starting in .NET 9:

Version introduced

.NET 9 Preview 6

Type of breaking change

This change is a behavioral change.

Reason for change

Before this change, it wasn't possible to use Environment.SetEnvironmentVariable(String, String) to set an environment variable to an empty value, which is a valid environment variable value on all supported platforms.

Recommended action

To delete an environment variable using Environment.SetEnvironmentVariable(String, String), change your code to pass null instead of string.Empty as the value argument.

To set the environment variable to an empty value using ProcessStartInfo.Environment or ProcessStartInfo.EnvironmentVariables, change your code to set these properties to string.Empty instead of to null.

Affected APIs

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.

Additional resources

In this article

Was this page helpful?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4