.net 转换任意类型不报错

代码
public  T CastAll < T > ( object  value)
        {
            T temp 
=   default (T);
            
try
            {
                temp 
=  (T)value;
            }
            
catch
            {
                temp 
=   default (T);
            }
          
            
return  (T)temp;
        }

 

你可能感兴趣的:(.net)