Generic method RRS feed

  • Question

  • User594242481 posted

    Hi everyone,

    I am trying to write some generic method which should get user setting from databse in right type with its value.

    For now I have following method outline:

    class SettingsManager
            public static T GetValue<T>(string parameterName, object defaultValue)
                // Gets the value from db according to parametrName
               // Some code to get parametr value from db
               Type t = typeof(T);
               // ....

    And I dont know how to create new type bysed on <T> and give it the value from db and return it :(

    Thank you for your help.

    Saturday, October 1, 2011 12:35 PM


  • User-824764785 posted

    i've posted the complete code on this forums:- http://forums.asp.net/t/1714210.aspx/1?Where+i+can+Learn+More+About+Generic+T+

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 1, 2011 12:41 PM