c# 类型转换

public static T1 Cast<T1>(object obj) where T1 : class
        {
            T1 r = obj as T1;
            if (r == null)
            {
                throw new Exception("Object cast fase.");
            }
            return r;
        }

mark

posted @ 2020-01-16 14:16  天天的蓝色  阅读(175)  评论(0编辑  收藏  举报