How do I make the return type of a method generic?

Is there a way to make this method generic so I can return a string, bool, int, or double? Right now, it’s returning a string, but if it’s able find “true” or “false” as the configuration value, I’d like to return a bool for example.

    public static string ConfigSetting(string settingName)
    {  
         return ConfigurationManager.AppSettings[settingName];
    }

7 Answers
7

Leave a Comment