Environment.GetEnvironmentVariable(EnvironmentVariables.AspnetCoreEnvironment) equivalent 3.1 code example
Example: csharp check if env is development
bool isDevelopment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development";