C#语言基础(unity)
一、.NET简介:
dotnet:Microsoft新一代多语言的开发平台,用于构建和运行应用程序;
c#(sharp):Microsoft专为.NET推出的高级编程语言;
Mono:Novell公司支持在其他操作系统(Linux,iOS)下开发.NET程序的框架;(unity借助Mono实现跨平台,核心是.NET Framework框架)
下面展示一些 内联代码片
。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleDay01
{
class Programa
{
static void Main(string[] args)
{
Console.WriteLine("Hello,World!");
string name= Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleADay01
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入姓名:");
string name=Console.ReadLine();
Console.WriteLine(name);
Console.ReadLine();
}
}
}
(生成-exe-运行);
c#文件后缀名称:.cs;
WirteLine(将括号内容写入console);
ReadLine(将括号内容读到程序(name)中);
在console(控制台)显示括号内的内容;
二、
1.console是类(工具,后有.来调用属性和方法),WriteLine/ReadLine是方法(功能,后跟小括号),Title是属性(修饰);
类.方法(“”);类.属性=“”
2.class来定义类(做工具);
namespace定义命名空间(工具的存放地址):对类进行逻辑上的划分,避免重名;
using来引入命名空间如system下的console;
vs独立快捷键:
Ctrl + K +F自动对齐
Ctrl +K+C注释选中的代码
Ctrl+ K +U取消注释