C#第二章学习的代码

本文介绍了C#程序的基本结构,包括命名空间的使用、关键字的应用以及编程规范等内容。通过实例展示了如何创建简单的C#程序,并对命名空间、Main方法等核心概念进行了说明。

 

2._1_Csharp程序结构
using System;

//引用命名空间

namespace _2._1_Csharp程序结构
{
    class Program//Program类
    {
        static void Main(string[] args)//static静态 void 无返回值 Main函数 也是我们程序执行的起点
        {
            Console.WriteLine("Csharp结构");
            Console.ReadKey();
        }
    }
}
//命名空间或者项目名称
2._2命名空间标识符关键字
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using @class = System.Console;

namespace _2._2命名空间标识符关键字
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("这是一条 输出语句");

            @class.WriteLine("这是一条别名输出语句");
            Console.ReadKey();
        }
    }
}
2._3编程规范
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2._3编程规范
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("这是第一行");
            Console.WriteLine("这是第二行");
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace _2._4_本章总结及任务实施
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("这是第4节本章总结及任务实施");
       


            Console.ReadKey();
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 一个解决方案下第二个项目
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("第二项目");
            Console.ReadKey();
        }
    }
}

 

转载于:https://www.cnblogs.com/zqyo2000z/p/5338727.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值