天天看點

資料類型轉換執行個體(C#)

/* 

* 數值轉換為字元型方可輸出 

*/

using System; 

using System.Collections.Generic; 

using System.Linq; 

using System.Text;

namespace ConsoleApplication2 

    class Program 

    { 

        static void Main(string[] args) 

        { 

            double staff1 = 1480.32; //員工1工資double類型 

            string strStaff = Convert.ToString(staff1); //轉換為字元類型 

            Console.WriteLine("員工1的本月工資是:{0}元",strStaff); //将轉換結果輸出

            int staffall = 80; //員工的人數為整形 

            string strStaffall = Convert.ToString(staffall); //轉換為字元類型 

            Console.WriteLine("公司現有員勞工數是:{0}人", strStaffall); //将轉換結果輸出 

        } 

    } 

}

本文轉自 makewong 51CTO部落格,原文連結:http://blog.51cto.com/makewong/293042,如需轉載請自行聯系原作者