Using Generics to return a literal string or from Dictionary

前端 未结 5 1799
刺人心
刺人心 2021-01-23 08:04

I think I outsmarted myself this time. Feel free to edit the title also I could not think of a good one.

I am reading from a file and then in that file will be a string

5条回答
  •  余生分开走
    2021-01-23 08:45

    if(typeof(T) == typeof(string))
    {
        return (T)Parameter;
    }
    else
    {
        // convert the value to the appropriate type
    }
    

提交回复
热议问题