Search code examples
c#xmlpropertiesresx

Can I pass multiple values into a Setter in C#?


Hello all I'm trying to build a save settings and to not expose my methods I'm trying to hide as many methods as I can from the actual runtime and running them all from setters and getters for all my IO.

I need to be able to pass both the Uri of a file location and a Dictionary into a method in order to do the call. I would put the file location into the resx, but I have to be able to allow system admins to change the locations of the files. all i am loading is in key value pairs into an xml.

What is going to be the best way to do this?


Solution

  • You can use Tuples (when using .Net Framework 4.0+).

    class SettingsClass
    {
        public Tuple<string, Dictionary<string, string>> TwoValuesProperty { get; set; }
    }
    

    And then you can use it by:

    SettingsClass settings = new SettingsClass();
    
    settings.TwoValuesProperty = new Tuple<string, Dictionary<string, string>>("URI", new Dictionary<string, string>());