• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

c#第一课helloworld

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本来是第一周的课程,可是由于这个软件太大了,我的流量不够用了,耽误了,只能延后一周交作业了,希望老师原谅。

下面开始说说c#这门语言吧

•C# Features
üAll in one(不需要描述Class的头文件或IDL), and XML inline documentation in Source.
üC# also supports interface(接口).
üC# also provides support for struct(结构体).
üC# provides full support of delegates(委托).
üC# provides component-oriented features(面向组件特性):such as property(属性), event(事件), and declarative constructs (such as attribute(性质)).Compiled code is Assembly(程序集).
 
编程实例
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

System.console.Title = "hello"; //设置标题
System.Console.BackgroundColor = System.ConsoleColor.Blue; System.Console.ForegroundColor = System.ConsoleColor.Yellow; System.Console.WriteLine("hello world"); System.Console.WriteLine(args[0]); for (int i = 0; i < 3;i++ ) { System.Console.WriteLine("nihao " + args[i]); } Console.ReadLine(); } } }

 代码分析

c#中 可以用// , /*     */,///来给代码添加注释。

在程序开头加上 using System 可以简化程序。如果加上的话,那么输出helloworld的代码可以写成 Console.WriteLine("hello world");

System.Console.Title = "hello"; //这是设置黑方框标题的语句,将标题设成了hello

System.Console.BackgroundColor = System.ConsoleColor.Blue;
System.Console.ForegroundColor = System.ConsoleColor.Yellow; 

/*这两句代码设置输出的字体的颜色,背景颜色设成了blue,输出字体颜色为黄色*/

 

System.Console.WriteLine(args[0]);
            for (int i = 0; i < 3;i++ )
            {
                System.Console.WriteLine("nihao  " + args[i]);
            }

          

首先 我把命令行参数设成了hello google baidu,中间用空格隔开。 

System.Console.WriteLine(args[0]);//这段代码就会输出命令行的第一个参数hello。

 

  Console.ReadLine();/*   直接点击“启动”按钮,出现黑方框后会闪退,加上这句代码后,就不会闪退了。(百度的) 。  如果不加这段代码的话,用Ctrl + f5也不会闪退。

输出结果

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#中对泛型List进行分组输出元素发布时间:2022-07-10
下一篇:
C#dynamic使用发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap