C# 如何四捨五入 (*^__^*) 嘻嘻……

/// <summary>
        /// 四捨五入
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public int sishewuru(string str)
        {
            if (str.Length > 9)
            {
                str = str.Substring(0, 8);
            }

            return Convert.ToInt32(Math.Round(Convert.ToDouble(str), 1, MidpointRounding.AwayFromZero));
        }


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章