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

原文地址:https://www.cnblogs.com/huanyun/p/12200948.html