Fork me on GitHub

C#中将string转换为float

            string s = "123.2";
 
            //方法1
            float f1 = Convert.ToSingle(s);
 
            //方法2
            float f2;
            if (!float.TryParse(s, out f2))
            {
                Console.WriteLine("无法转换!");
            } 

 

float volume = 0.5F; //double 转float

 

posted @ 2017-06-24 19:33  RongT  阅读(71393)  评论(0编辑  收藏  举报