if---(switch-case)语句初步学习总结
2014-03-10 19:06
363 查看
Daily sentence: Happiness is about having each tiny wish come true. 幸福就是达成每一个Tiny Wish.
Ctrl+E D C#自动排版.
强制转换:
如果表达式中含有一个double类型的的操作数时候,整个表达式都提升为double类型.
int a=(int)3.14; 将3.14强制转换为int类型.并将值赋给a.
int 变量Convert.ToInt32(Console.ReadLine(输入的字符串)); 将输入的字符串转换为int类型.
Convert转换不再仅是内存级别的转换,而是考虑数据意义的转换.Convert是一个加工转换的过程.
(要明白为什么转换?!)
Convert.ToInt32();
Convert.ToString(); (一切类型都可以转换成string类型)
int a = 10;
Console.WriteLine(a.ToString()); 将int转换为string类型.
View Code
Long way to go......
Ctrl+E D C#自动排版.
强制转换:
如果表达式中含有一个double类型的的操作数时候,整个表达式都提升为double类型.
int a=(int)3.14; 将3.14强制转换为int类型.并将值赋给a.
int 变量Convert.ToInt32(Console.ReadLine(输入的字符串)); 将输入的字符串转换为int类型.
Convert转换不再仅是内存级别的转换,而是考虑数据意义的转换.Convert是一个加工转换的过程.
(要明白为什么转换?!)
Convert.ToInt32();
Convert.ToString(); (一切类型都可以转换成string类型)
int a = 10;
Console.WriteLine(a.ToString()); 将int转换为string类型.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace switch_case { class Program { static void Main(string[] args) { Console.WriteLine("请输入一个字母(A-E)?"); string input = Console.ReadLine(); int salary = 5000; bool sign = false; switch(input) { case "A": salary += 500; break; case"B": salary += 200; break; case"C": break; case"D": salary -= 200; break; case"E": salary -= 500; break; default: Console.WriteLine("你输入的英文字母有错误!"); sign = true; break; } if (sign == false) { Console.WriteLine("你的工资是" + salary); } Console.ReadKey(); } } }
View Code
Long way to go......
相关文章推荐
- C/C++学习(一)题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
- 【学习ios之路:C语言】布尔类型,关系运算符、逻辑运算符、if 、switch..case.语句
- 智力题总结——求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
- 每天学习一算法系列(12) (求1+2+…+n,不能使用乘除法,for、while、if 、else、switch、case 等关键字以及条件判断语句)
- 【练习】题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case 等关键字以及条件判断语句
- JAVA学习(四):Java流程控制语句(顺序结构、if条件语句、switch条件语句、循环语句与跳转语句)
- MySQL的if,case语句使用总结
- MySQL if case语句使用总结
- 求1+2+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句
- MySQL的if,case语句使用总结
- 求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字 以及条件判断语句(A?B:C)
- MySQL的if,case语句使用总结
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
- 求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)
- MySQL的if,case语句使用总结
- JavaScript中switch...case语句与if...else性能比较
- 求1+2+3+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
- 求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)。
- 题目:求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case 等关键字以及条件判断语句
- 求1+2+…+n 要求不能使用 乘 除 法、for、while、if、else、switch、case等关键字以及条件判断语句