C# for Beginner session 10 to 20

Session 11-12 switch statement in C#

switch statement

break statement   if break statement is used inside a switch statement,he control will leave the           switch statement

goto statement    you can either jump to another case statement,or to specific label(label is some          word you coding to mark).

         Warning:Using goto is bad programming style,we can should avoid go to by all            means

Multiple if else statements can be replaced with a switch statement

for an excample:

if(number ==10)

{Console.WriteLine("you number is 10");}

else if(number ==20)

{Console.WriteLine("you number is 20");}

else if(number ==30)

{Console.WriteLine("you number is 30");}

else

{Console.WriteLine("you number is not 10 to 30");}

above code can be replaced as:

switch(number)

{

  case :10

  Console.WriteLine("you number is 10");

  break;

  case :20

  Console.WriteLine("you number is 20");

  break;

case :30

  Console.WriteLine("you number is 30");

  break;

defalut:

  Console.WriteLine("you number is not 10 to 30");

}

or can be replaced as:

switch(number)

{

  case:10

  case:20  

  case:30

  Console.WriteLine("you number is{0}",number);

  default:

  Console.WriteLine("you number is not 10 to 30");

}

Noted that switch(expression) , expression value must be bool , char, string, int ,enum or nullable type.

Session 13 while loop in c#

1,while loop checks the condition first.

2,if the condition is true,statements with in the loop are executed.

3,this process is repeated as long as the condition evaluetes to true.

Note:Don‘t forget to update the variable participating in the condition,so the loop can end , at some point

Session 14 while loop in c#

1,a do loop checks its condition at the end of the loop.

2,this means that the do loop is guranteed to execute at least one time.

3,do loops are used to present a menu to the user

Difference -while & do while

1,while loop checks the condition at the beginning, where as do while loop checks the condition at the end of the loop.

2,do loop is guaranteed to execute at least once, where as while loop is not

时间: 2025-01-14 12:39:44

C# for Beginner session 10 to 20的相关文章

Install MariaDB Galera Cluster 10.0.20

安装环境: OS:Centos 6.6 [[email protected] ~]# uname -a Linux heartbeat1 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux 数据库软件:MariaDB Galera Cluster 10.0.20 主机配置: Heartbeat1 10.0.0.7 Heartbeat2 10.0.0.8 Heartbeat

//随机生成 10到20条数据 数据包含 用户名(5-10位的字母) 性别 年龄(1-100岁)

//随机生成 10到20条数据 数据包含 用户名(5-10位的字母) 性别 年龄(1-100岁)/*生成随机数的方法*/function random(min, max) { if (min < 0 || max < 0) { console.log("请输入大于0的数据"); return false } if (max == null) {//判断如果只传入一个参数 var max = min;//将参数设置为最大值 min = 0;//将最小值设置为零 } retur

中级学员:2015年10月20日作业

中级学员:2015年10月20日作业一.项目沟通管理:1.项目沟通管理包括哪些过程:2.沟通管理计划的主要内容:3.项目干系人管理的方法(12.6.2)二.项目合同管理:4.无效合同的五条:5.总价合同的特征,及签订前提条件:6.合同质量.履行地点.履行期限.履行费用不明确的,分别如何处理:7.合同管理的主要内容包括哪四条:8."公平合理"是合同变更的处理原则,变更合同价款按哪些方法进行:9.项目索培的程序,包括哪六步. 最晚提交时间:下次上课前. 提交方法:同学们按照要求完成作业,并

使用RPM包离线安装MariaDB 10.0.20 , 基于CentOS 6.6-x86-64

使用RPM包[离线]安装 MariaDB 10.0.20,基于CentOS 6.6-x86-64 Minimal 湘中朱生 2015-07-01 于深圳福田 QQ: 872007255 MariaDB交流群: 198111730 文档说明: 1. 网上有很多关于MariaDB/Mysql数据库的安装技术博客文档,主要有源码编译安装和Yum源安装,有些写得很规范优秀,但很少有基于离线RPM包安装的. 2. 源码编译安装对于初学者而言门槛过高, 很容易打击MariaDB初学者学习探索的积极性; Yu

简单程序题:abcd四个项目收益顺序分别占10%,20%,30%,40%

abcd四个项目收益顺序分别占10%,20%,30%,40%,当有一个项目不存在时则该项目收益归上一个项目,项目a 始终存在,封装一个函数得到abcd的收益: 这题不难,关键点是要想到用数组,这点想到了,那肯定能做出来. 程序代码: <?php /**     * 获取项目收益     * @param null $b     * @param null $c     * @param null $d     * @return array*/    function getIncome($b

10月20日全球域名商解析新增量TOP15:万网第三

IDC评述网(idcps.com)10月23日报道:根据DailyChanges公布的最新数据显示,在2015年10月20日,全球域名解析新增量十五强大战中,DOMAINCONTROL.COM凭借29,619个新增量拔得头筹,遥遥领先众多域名商.易名中国.中国万网分列2.3名,相比上期,排名两两互换,新增量依次为11,736个.10,993个.接下来,请看IDC评述网对相关数据进行整理与分析. (图1)全球域名解析商(国际域名)解析新增量Top15分布图 从图1中可了解到,在10月20日,全球域

10月20日中国域名商解析量十四强:易名中国季军

IDC评述网(idcps.com)10月22日报道:根据DailyChanges公布的实时数据显示,截止至2015年10月20日,国内域名解析量前三名是中国万网.DNSPod.易名中国,域名解析量分别达到3,462,650个.1,942,018个.1,112,805个.其中,易名中国排名环比上期10月13日上升1位.下面,请与IDC评述网一起关注10月20日中国域名商解析量十四强排行榜. (图1)中国域名解析商(国际域名)解析量排行榜TOP14分布图 由图1可知,在2015年10月20日国内域名

QueuePool limit of size 10 overflow 20 reached, connection timed out, timeout 10

当批量删除虚拟机时报错如下 1.在计算节点的报错信息如下 [[email protected] ~]# tail -f /var/log/neutron/openvswitch-agent.log 2014-09-02 19:28:27.252 36649 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.6/site-packages/neutron/agent/security

10月20日上午SQl数据库作业解析

设有一数据库,包括四个表:学生表(Student).课程表(Course).成绩表(Score)以及教师信息表(Teacher).四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表(一)~表(四)所示.用SQL语句创建四个表并完成相关题目.                  表1-1数据库的表结构 表(一)Student (学生表)                         字段名 数据类型 可否为空 含 义 Sno varchar(20) 否 学号(主键) Sname