zoukankan      html  css  js  c++  java
  • c#第一课 hello world

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

    下面开始说说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也不会闪退。

    输出结果

     

  • 相关阅读:
    POJ 1320 Street Numbers(佩尔方程)
    hdu 3292 No more tricks, Mr Nanguo
    佩尔方程
    hdu 4825 xor sum(字典树+位运算)
    Xor Sum 2(位运算)
    数串
    EJS
    JQuery性能优化
    常用正则
    JavaScript prototype继承中的问题
  • 原文地址:https://www.cnblogs.com/GSONG/p/4366260.html
Copyright © 2011-2022 走看看