Convert类型转换
static void Main(string[] args) { //Convert转换:不同数据类型之间的转换; //大前提: 面儿上一定要过得去 Console.WriteLine("请输入你的姓名:"); string strName = Console.ReadLine(); Console.WriteLine("请输入你的数学成绩:"); double douMath = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("请输入你的语文成绩:"); double douChinese = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("请输入你的英语成绩:"); double douEnglish = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("{0},你的总分是{1}, 你的平均分是{2:0.00};", strName, douMath + douChinese + douEnglish, (douMath + douChinese + douEnglish) / 3); if (douMath>=60 && douChinese>=60 && douEnglish>=60) { Console.WriteLine("恭喜你,成绩合格!"); } else { Console.WriteLine("很抱歉, 你的部分成绩不合格!"); } Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("46天是{0}周零{1}天;", 46 / 7, 46 % 7); Console.ReadKey(); }
static void Main(string[] args) { const int intAllSecond= 107653; int intDay = intAllSecond / (24 * 60 * 60); int intHour = (intAllSecond % (24 * 60 * 60)) / (60 * 60); int intMinute= ((intAllSecond % (24 * 60 * 60)) % (60 * 60))/60; int intSecond= intAllSecond % 60; Console.WriteLine("{0}天,{1}时,{2}分,{3}秒", intDay, intHour, intMinute, intSecond); Console.ReadKey(); }