using System;
using System.Collections.Generic;
namespace MyProject
{
public class Models
{
public static class Vars
{
public static readonly Dictionary<string, string> VarToValue = new Dictionary<string, string>
{
{"var1", "value1"},
{"var2", "value2"},
{"var3", "value3"},
{"var4", "value4"}
};
public static string GetValueFromVar(string svar)
{
if (VarToValue.ContainsKey(svar))
{
return VarToValue[svar];
}
throw new ArgumentException($"{svar} is not a valid key");
}
}
}
}
The value of any variable in 'Vars can now be accessed from anywhere in the 'MyProject namespace:
string test1 = MyProject.Models.Vars.GetValueFromVar("var1");