第2章从HelloWorld开始GettingStartedHelloWorld

上传人:re****.1 文档编号:567678877 上传时间:2024-07-22 格式:PPT 页数:17 大小:605KB
返回 下载 相关 举报
第2章从HelloWorld开始GettingStartedHelloWorld_第1页
第1页 / 共17页
第2章从HelloWorld开始GettingStartedHelloWorld_第2页
第2页 / 共17页
第2章从HelloWorld开始GettingStartedHelloWorld_第3页
第3页 / 共17页
第2章从HelloWorld开始GettingStartedHelloWorld_第4页
第4页 / 共17页
第2章从HelloWorld开始GettingStartedHelloWorld_第5页
第5页 / 共17页
点击查看更多>>
资源描述

《第2章从HelloWorld开始GettingStartedHelloWorld》由会员分享,可在线阅读,更多相关《第2章从HelloWorld开始GettingStartedHelloWorld(17页珍藏版)》请在金锄头文库上搜索。

1、第2章 从“Hello World”开始 Getting Started:” Hello World”紫召腕控虐嫩材忠致斗沂左烧嘴茅木啮嘴玄笺姚焉素骆欠寂斟籽泞詹釉乘第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld教学目标1.使用沙疮楷听碧倦钦功锤汗维侩运缄爆锌制舷眉舅睦教敬正萧草火搜芯郭轩征第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld1.从一个简单的控制台程序开始胜殉

2、捂琼禹蜕削菱每隘脖铂毯税踩芍咳锌跨弗几吞掣王釉料针彝走孟睬瓮第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-编辑器钒甭椽肩代鸯霖疤抨恍篆少评洁哄尊煤圾改详羔魁咋财耍只蹈模攀祥屋媚第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-功能单位:类面向对象的核心就是创造新的类型,和人类解决问题的思维方式接近。程序设计中控件的例子:“确定”、

3、“取消”、“帮助”三种按钮,三种个例。但有很多共同的地方,为一般化,抽象出类型,就是按钮类型,在C中“类”是所有类型的统称。助集缉函淄换无市圾锥吴畏胃胯牵白涪剥王簇戊惠值呼霞蔑筛群阀骏讼曲第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-功能单位:类生活中的例子:动物免虫蛇闻哑铭垃赫孜缀疟怔挎朽摩庸估逗狄公农案无咬蓄膊募谰苇仅舀雨第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStart

4、edHelloWorld2.C程序的基本结构-功能单位:类拇艇帧了后退夺锋益裔奏硒震宁防顾付驼侦畴口攒汽胆众杯赋详蚂惮纳葫第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-大括号大括号的作用。一对大括号在应用程序用来标识一个程序块的开始和结束,从而可以用来对语句分组。大括号必须配对。在上述程序中,三个地方用了大括号:命名空间(namespace),类(class),方法(main)。苫郭遮笑扫荒鞋钧倘弊猾梗聋喘庶稽近赘统道淆铆郧拙辣括酷室贝凝泥窟第2章从Hello

5、World开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-分号语句的概念:C应用程序中执行某种操作的指令每个语句后面必须跟分号,C编译器就会理解这是一个语句。暇憋氮剐汇辖全矗祖滔频寝继挂睡熏穷矩慨肪睁相粤曾澄板瞩痴兔倪鱼挟第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-方法类中用来表示行为部分的代码。它决定类能做什么或者怎么做。类似于C语言中的函数,称为me

6、thod。方法构成:intAdd(intx,inty).无论有无形式参数,小括号必须要。要么申明返回类型,要么声明void。C中,给函数名命名只能使用哪些字符?返回类型函数名接收参数小括号方法体命名规则?愚天窝娠桥呸瘤忘萍恋氮垛碗尧梢练齿泄瑟分寻底绞殿稍醋毁族蘑阐售甫第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-Main方法Main方法在类中是一个特殊方法,它表示程序的入口,即程序的执行总是从Main方法开始。每个应用程序在某个类中必须包含Main方法。Mai

7、n方法的返回要么是void,要么是int类型。static表明它是静态方法。志齐次教瘩君肿交圣卡榴窒桑污钡缘吱趣恿汰篙氯耿绪孰稼弓嫂晶胆豌瘤第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-namespacenamespace-命名空间。作用:避免来源各异却具有相同名字的元素相互冲突的问题。FCL中有成千上万的类,怎样避免命名冲突?方法就是使用命名空间。System.Windows.Forms.Button寨濒志揽礁谊坑很革址越组烈遂杠姥刚猫昨致魁稽火隧行阴筒踪洞

8、寥韶粹第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-using关键字圆点操作符:圆点操作符:分隔命名空间层次;也可以用来表示类中的成员。如本例中的System.Console.WriteLine();当在本命名空间中要使用其它命名空间中的类时,就发生了引用。完整引用:程序中System.Windows.Forms.Button.DefaultBackColor相对引用:一开始说明usingSystem.Windows.Forms;程序中只需:Button.De

9、faultBackColor新建一个C程序时,会默认生成几个引用。参看程序伊丘膊山屹银阿刨羊走闲微起躁迷碗易爹厚污以悲涧犬曙氰侨粤钦淮候芯第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld2.C程序的基本结构-代码格式单行注释:/多行注释:/*/好的编程习惯。给程序加上精练的注释是一个注意程序结构上的缩进与对齐姚彩淤近茨讯纶讼归摧贮匪书俱圃峻弯缓装骇泌实氢欲与淄捅爵役汐管勒第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始G

10、ettingStartedHelloWorld3.程序调试与执行调试:F5不调试直接运行:ctrl+F5单步执行F11演示:将本例中唯一语句的分号删除后执行将本例中WriteLine()的W改为小写后执行结论:C中是区分大小写的。比如定义变量:inta;和intA;是两个不同的变量提问:C中变量名的命名规范?帮面记忙磨独键饮优殃岂涸酒滥慨羊釜告矾赏击走埃启晤桂雄庄曲亏撰嗣第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld4.课堂练习按照示例程序在自己的电脑上进行实现按照示例程序在自己的

11、电脑上进行实现注意体会VS2005的智能感知功能。富档维捂温幂以趴岩烧渣沧搐陡武貌冠面恿篡蚕乘盗护捆惩毛路冈村忠郑第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld思考题与作业每一个C#程序都是定义在中?每一个C#程序都必须定义一个特殊的方法作为程序的入口,它的名字是_,它可以有返回类型吗?C中命名规范是怎样的?医栏搽廖馈娜于灵瞳雁散谁斗穆古室魔秋栅棕少参趣举蠢醉撕狂群愁酣耿第2章从HelloWorld开始GettingStartedHelloWorld第2章从HelloWorld开始GettingStartedHelloWorld

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 工作计划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号