.net 通过泛型取值

public static T GetValue<T>(string Key)
        {
            T result = default(T);//这个default是先取泛型的默认值
            result = (T)Convert.ChangeType(_config[Key], typeof(T));//然后在这里进行强转
            return result;
        }

 

posted @ 2019-06-28 17:24  健忘就忘吧  阅读(346)  评论(0编辑  收藏  举报