0

Is it possible to obtain the value of this configuration in code? I've tried inheriting the Switch class to another class and printed the Value property, but it returns a zero value.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>
 <system.diagnostics>
  <switches>
   <add name="mySwitch" value="Data Access" />
  </switches>
  
 </system.diagnostics>
</configuration>
 class SwitchSample : Switch
{

    public SwitchSample(string displayName, string description) : base(displayName, description)
    {
        Console.WriteLine(Value);     
    }

    public SwitchSample(string displayName, string description, string defaultSwitchValue) : base(displayName, description, defaultSwitchValue)
    {
    }
}
class Program
{
    static void Main(string[] args)
    {
        SwitchSample ss = new SwitchSample("disp", "desc");

        Console.ReadKey();
    }
}

The value property is what I'm trying to get.

Ronald Abellano
  • 774
  • 10
  • 34

0 Answers0