Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
C# Programming Ch 01 變數宣告及運算子 Visual Studio 2013 下载及版本 • Visual Studio 2013 Express for Desktop(Free) • http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx • Express for Web, Window, Windows Desktop, Team Foundation Server .Net Framework • .NET Framework是一个框架,它包含 • 类别库 (Framework Class Library , FCL) • 执行环境 (Common Language Infrastructure ,CLI) • 通用语言执行平台 (Common Language Runtime, CLR) • • • • 例外处理 (exception handling) 垃圾回收 (garbage collection) 安全 (Security) 线程管理thread management (Java bytecode) (Java JVM) 在Visual Studio .Net 新增及重开专案 HelloTaiwan using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace HelloTaiwan { class Program { static void Main(string[] args) { Console.WriteLine("Hello Taiwan"); Console.ReadLine(); } } } 1. 程序代码必需缩排,容易阅读 2. 项目的所有档案,预设存在users的 documents->Visual Studio 2013目录下。 3. IDE开发环境,对开发阶段时对错误的语 法会以特别的形式标出(如红色波浪底线)。 4. 若将鼠标移到错误的语法,IDE会提示此 错误的原因及建议解决的方法。 5. IDE会将程序不同的部分以不同颜色标示 (如保留字用蓝色、Class用绿色、字符串 用红色) 6. 若将鼠标移到类别或方法名称上,IDE会 提示此类别或方法的说明。 7. 学习程序设计是学习程序语言的基本语 法(如变量宣告、控制结构等),及预先建 立的函示库 (如Console.WriteLine等) 8. Intellisense:在一个类别或对象后按.会列 出此类别或对象可使用properties 和 方法 練習題(1) • 請在您的電腦執行上一張投影片的程式碼 Package -> Class -> Method 例:System.Console.WriteLine(“Hello Taiwan”) System 是package name Console是 Class name WriteLine是method name 練習題(2) • 請在您的電腦執行上一張投影片的所有程式碼 变量宣告与操作(Declare variable) 1. 2. 3. 4. 5. 6. int x; int y; x = 7; y = x + 3; Console.WriteLine(y); Console.ReadLine(); 1. 宣告变量x(系统会为x配置一个int 的 内存空间) 2. 宣告变量y(系统会为y配置一个int 的 内存空间) 3. 指定整数7给变数x (系统会在x的内存 空间放置整数7) 4. 指定x+3的结果给变量y(由内存取出x 的值, 再加3, 结果放入y在内存的位置) 实值型别 • 实值(数字,布尔,结构struct,列举enum)和参考型别(用户自定义的类 别对象) 变数转换 • 隐含转换(Implicitly convert )及明确转换(Explicitly convert) • 变数命名须一致 • 常用camel case 如 myFirstName • 批注(comment) 1. 2. 3. // /* */ 批注选取按钮 練習題(3) • 請在您的電腦執行上一張投影片的程式碼