using static System.Environment;
class Program
{
static void Main()
{
// Get the named env var, and assign it to the value variable
var value =
GetEnvironmentVariable(
"ENVIRONMENT_VARIABLE_KEY");
}
}
#include <iostream>
#include <stdlib.h>
std::string GetEnvironmentVariable(const char* name);
int main()
{
// Get the named env var, and assign it to the value variable
auto value = GetEnvironmentVariable("ENVIRONMENT_VARIABLE_KEY");
}
std::string GetEnvironmentVariable(const char* name)
{
#if defined(_MSC_VER)
size_t requiredSize = 0;
(void)getenv_s(&requiredSize, nullptr, 0, name);
if (requiredSize == 0)
{
return "";
}
auto buffer = std::make_unique<char[]>(requiredSize);
(void)getenv_s(&requiredSize, buffer.get(), requiredSize, name);
return buffer.get();
#else
auto value = getenv(name);
return value ? value : "";
#endif
}
import java.lang.*;
public class Program {
public static void main(String[] args) throws Exception {
// Get the named env var, and assign it to the value variable
String value =
System.getenv(
"ENVIRONMENT_VARIABLE_KEY")
}
}
// Get the named env var, and assign it to the value variable
NSString* value =
[[[NSProcessInfo processInfo]environment]objectForKey:@"ENVIRONMENT_VARIABLE_KEY"];