实验一 介绍C.doc

  1. 1、本文档共60页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实验一 介绍C

实验一 C#语言介绍变量使用基础知识类的概念,C#基本知识类对象,执行C#程序hello world Tom said Hello to you Hello!’打印出单引号’ C:\Windows\System32\sas.dll 教师讲解分析问题,给出解决思路 逐字字符串常数以@开头,后跟一对双引号,在双引号中放入字符。如: @电子高专 @This is a book. 逐字字符串常数同常规字符串常数的区别是, @ hello \t world 实际输出:hello \t world 完成步骤: (1)为解决方案创建一个名为Example_1_1的控制台应用程序 打开Visual Studio2010应用程序,选择“文件”→“新建”→“项目”,左侧模板语言选择为“Visual C#”,右侧选择“控制台应用程序”,名称中填写“Example_1_1”,单击位置后的“浏览”按钮,选择存放的路径为“D:\C#实验指导书\Chap1”,单击“确定”按钮。 (2)在Example_1_1名称空间的主方法Main中输入内容如下: static void Main(string[] args) { Console.WriteLine(hello\tworld); Console.WriteLine(Tom said \Hello\ to you); Console.WriteLine(Hello!\打印出单引号\); Console.WriteLine(C:\\Windows\\System32\\sas.dll); Console.WriteLine(@C:\Windows\System32\sas.dll); } (3)编译和执行程序,选择“调试” →“启动调试”选项来执行此应用程序。 运行结果如图1.1所示。 图1.1 2、问题描述 写出以下程序的输出结果: using System; using System.Collections.Generic; using System.Text; namespace Example_1_2 { class Program { static void Main(string[] args) { //货币格式 double i1=1234.789; Console.WriteLine({0,8:c}, i1); Console.WriteLine({0,10:c4}, i1); Console.WriteLine(); //整数格式 int j1=1234; Console.WriteLine({0:d}, j1); Console.WriteLine({0:d3}, j1); Console.WriteLine({0:d5}, j1); Console.WriteLine(); //科学计数法格式 int i2=123000; double j2=1234.5578; Console.WriteLine({0:E}, i2); Console.WriteLine({0:E}, j2); Console.WriteLine({0:e4}, i2); Console.WriteLine({0:e4}, j2); Console.WriteLine(); //浮点数格式 int i3=123000; double j3=1234.5578; Console.WriteLine({0,-8:f}, i3); Console.WriteLine({0:f}, j3); Console.WriteLine({0,-8:f4}, i3); Console.WriteLine({0:f3}, j3); Console.Writ

文档评论(0)

shenlan118 + 关注
实名认证
内容提供者

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

1亿VIP精品文档

相关文档