于今日起学习巩固C#基础函数
2020-12-01学习
本随笔用于我的回忆理解,记录当天学习过程,内容多从书中整理与自我学习了解,若有问题麻烦指正ui
之后有时间会单独分版块叙述spa
无论什么语言,都从一个Hello,World开始code
打开VS(我用的2017版)--file--new--project--console APP(.Net Framework)对象
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Main(string[] args) { Console.WriteLine("hello,world"); Console.ReadKey(); } } }
using用于引用类库blog
Main函数是程序入口string
C#是一种强类型语言,在使用任意一个对象前,必须声明这个对象的类型。it
本身整理了一下io
float类型的赋值后面要加f
float somervar = 0.1f
内置类型,能够显式或隐式的转换成另外一种类型
short x=10;
int y=x;//隐式转换
x=y;//编译错误
x=(short)y;//显式转换
转化方式取决于类型字节大小
基本的标识符,语句与表达式,变量和常量定义介绍就先略过,后续有时间补充
常量有一个提一下
定义一个固定的变量即常量
const float PI=3.141f(后续不可改变值)
枚举
枚举是一种独特的值类型,能够看做一个常量列表
enum FRUIT { Apple=0, Banana, //值为1 Cherry, //值为2 } FRUIT fruit = FRUIT.Apple; //当前水果类型为苹果