Last active
March 21, 2024 13:02
-
-
Save georgepaoli/55fe5994f6ad061241ef47ac21908042 to your computer and use it in GitHub Desktop.
EnvHelper - Helper to read variables in .env file using C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnvHelper | |
{ | |
public static string ENV_VAR_A => GetEnvVar(); | |
public static string ENV_VAR_B => GetEnvVar(); | |
public static string ENV_VAR_C => GetEnvVar(); | |
private static string GetEnvVar([CallerMemberName] string name = null) | |
=> Environment.GetEnvironmentVariable(name); | |
} | |
/* content .env file | |
ENV_VAR_A=value A | |
ENV_VAR_B=value B | |
ENV_VAR_C=value C | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment