百分比的算法

http://www.189works.com/article-48092-1.html

/// 

/// 得到百分比函数 
///  
///  
///  
/// 
 

string getPercent( object A, object B ) 
    { 
        double rate = new double(); 
        try 
        { 
            rate = Convert.ToDouble( A ) / Convert.ToDouble( B ); 
        } 
        catch (Exception exec) 
        { 
            return null; 
        } 
        return rate.ToString( "p" ); //格式为12.23% 
    }


 

你可能感兴趣的:(█小小代码,C#基础知识)