网站大量收购独家精品文档,联系QQ:2885784924

Visual C# 2008程序设计案例教程电子教案源代码 3.ppt

Visual C# 2008程序设计案例教程电子教案源代码 3.ppt

  1. 1、本文档共111页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
主讲教师: 本课学时: 联系方式: 第三章 C#编程基础 本章的学习目标 在C#中使用分支结构 掌握各种分支结构的区别 在C#中使用循环语句 掌握循环语句的相同和区别 了解和掌握数组 掌握函数的应用 知道和学会怎样用字符串 3. 1 分支语句 期末过后,班主任要将百分成绩转换为等级制,需要进行等级判断,90~100分为A,80~89为B,70~79为C,60~69为D,60分以下为E。这时必须转移或改变程序的执行的顺序。而用分支语句,能够容易地实现这一功能。 3. 1 分支语句 if语句??? switch语句?? 三元运算符 If语句 if语句 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace @if { class EvenOdd { public static void Main() { int a; a = Int32.Parse(Console.ReadLine()); if (a % 2 == 0) Console.WriteLine(This is even\n); else Console.WriteLine(This is odd\n); Console.ReadKey(); } } } 输出结果: Switch语句 各个 case 标签不必连续,也不必按特定顺序排列 default 标签可位于 switch…case 结构中的任意位置 default 标签不是必选的,但使用 default 标签是一个良好的编程习惯 每两个 case 标签之间的语句数不限 switch…case 语法: switch (选择变量) { case 值1: … break; case 值2: … break; case 值3: … break; ... ... default : … } 例 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace @switch._._.@case { class Program { static void Main(string[] args) { int i; for(i=0;i10;i++) switch (i) { case 0: Console.WriteLine(i is zero); break; case 1: Console.WriteLine(i is one); break; case 2: Console.WriteLine(i is two); break; case 3: Console.WriteLine(i is three); break; case 4: Console.WriteLine(i is four); break; default: Console.WriteLine(i is five or more); break; } Console.ReadKey(); } } } 输出结果: 三元运算符 condition ? first_expression : second_expression; 三元运算符 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 三元运算符 { class MainClass { static double sinc(double x) { return

您可能关注的文档

文档评论(0)

开心农场 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档