值类型和引用类型
值类型存在栈上,结构,枚举,数值类型
引用类型存在堆上,数组,类,接口,委托
把值类型存到引用类型中就是封箱,耗时
引用类型中的值类型是存在堆上,不是栈上,但是作为参数传递时,还是会被copy一份,而不是引用
局部变量的值类型存在栈中
http://blog.youkuaiyun.com/onafioo/article/details/68961341
关键字
sealed:修饰类防止继承,修饰方法防止被复写
params:修改函数的最后一个参数,用来传一个size不定的数组fun(params int[] b)
ref:控制参数以引用方式传递,func(ref int val)在函数内修改val会影响参数值。调用函数和定义函数都要有ref关键字
out:指定所给的参数是输出参数,也指定为引用传递,与ref不同的是,ref变量传递前必须有初始值。调用函数和定义函数都要有out关键字
as
is
数组
结构体
委托
http://blog.youkuaiyun.com/onafioo/article/details/49780591
lambert表达式
Action<int ,string>=(a,b)=>{..........}
delegate int MyDel(int i,int j);
MyDel del=(a,b)=>a+b; lambeda表达式方法
MyDel del = delegate(int a,int b){return a+b;}
MyDel del = new MyDel(funcA);
空方法
delegate MyDel();
del = delagate(){...}
del = ()=>{...}
异步
http://blog.youkuaiyun.com/onafioo/article/details/44356895
协程
http://blog.youkuaiyun.com/onafioo/article/details/71055295
线程
线程:
static void Main(string[] args)
{
Thread t1 = new Thread(new ThreadStart(TestMethod));
t1.Start();
}
public static void TestMethod()
{
Console.WriteLine("不带参数的线程函数");
}
事件
Class Compony{
public delegate void DeleFunc(int a);
public event DeleFunc eventListener;
public void DoEvent(){
if(eventListener!=null){
eventListerner(1);
}
}
void Main(){
Compony c = new Compony();
c.eventListener+=funcA();
c.DoEvent();
}
void funcA(int i){
print("funca");
}
}
泛型
反射
http://blog.youkuaiyun.com/onafioo/article/details/48974737