天天看点

VS2015的C#环境好搭建&hello word&命名空间的定义&类的定义

环境搭建

1.创建C#的信息.

VS2015的C#环境好搭建&hello word&命名空间的定义&类的定义

2.编写c#的hello Word

VS2015的C#环境好搭建&hello word&命名空间的定义&类的定义

c#编写hello word

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20200909tes1
{
class Program
{
static void Main(string[] args) //玫方法
{
Console.WriteLine("hello word");//打印hello word
Console.ReadLine();//固定框体
}
}
}
           

命名空间

命名空间-标设类的可见访问

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//通过1-5行执行第7行的命名空间

using Demo;//第8行 使能执行Demo空间

namespace Hello_word
//第1-5为命名空间 目的类的可见范围
//定义命名空间(hello word) 须使用namespace关键字
//格式:namespace 被定义的命名空间名称
{    
class Program
//类:program
{
Test test = new Test();    
/*hello word命名空间中使用Test??-1.先写关于Demo的命名空间
  2.在Demo空间中写关于Test的类
  3.开启第8行,使Demo的命名空间有效
  4.通过Test方法,Demo空间能够在Hello word命名中执行成功*/
static void Main(string[] args)
//main方法 
//hello word命名空间中使用main 
{
//打印数据
Console.WriteLine("Hello word");
Console.ReadLine();
//标识符(Console)
}
}
}

namespace Demo
{
class Test
//创建Test类
{

}
}
           

类-一种数据结构,存储数据成员,方法成员.其他等内容.方便调用;类名称不能重复

类-使用方法

class 类名
{
//类中的代码
}