
C#
做游戏的小轩轩
这个作者很懒,什么都没留下…
展开
-
Unity学习之C#
1,检查运算符:原创 2015-06-10 19:32:23 · 357 阅读 · 0 评论 -
C#装箱拆箱 Nullable
装箱:把值类型转换为引用类型 拆箱:把引用类型转换为值类型 值类型存储在内存的栈上,引用类型在栈上存一个引用,在堆上存储具体的值 int? iNullable = null;//int?相当于下面这一行 System.Nullable iNUllable2 = 100; //Nullable防止拆箱时出错 iNuaable.Value //为空时报错,一般不用 iNu原创 2015-08-15 11:50:35 · 410 阅读 · 0 评论 -
C# 使用Method进行转换
int iFromS = Convert.ToInt32("100"); int iFromS2 = Int32.Parse("100"); int iFromS3 ; bool succeed = Int32.TryParse("100",out iFromS3); //前两个如果格式不对,会抛出异常,后面一个如果格式不对不会抛出异常但也不会转换为值.原创 2015-08-15 11:32:38 · 932 阅读 · 0 评论 -
C# abstract类 和 interface 的 区别
abstract类不能实例化,抽象类也有自己的变量,方法,继承抽象类的类必须实现抽象类的抽象方法,并且它也继承了抽象类的其他属性。 interface,不能有自己的成员变量,继承interface的类必须实现其方法。 C#只能继承一个类,可以继承多个接口原创 2015-08-15 11:00:55 · 341 阅读 · 0 评论 -
C# StringBuider
如果要频繁的对string 进行修改时,要使用StringBuilder StringBuilder builder = new StringBuilder(); builder.Append("xuanxuan"); builder.Append("minmin"); String string = new string(); string = builder.toString();原创 2015-08-15 10:24:43 · 451 阅读 · 0 评论 -
C# 集合类型
数组,arrayList List Hashtable Hashtable ht = new Hashtable(); ht.Add("first","xuanxuan"); ht.Add("second","minmin"); //通过这样访问ht["second"] 使用无效的key查找是返回null 而dictionnary抛出异常 Hashtab原创 2015-08-15 14:29:13 · 271 阅读 · 0 评论 -
C# 逻辑语句
if(& ) if( | ) 单个的逻辑运算符会把所有表达式计算一遍, int ifelse = x < 100 ? x : 99; 如果前面条件成立返回x,不成立返回99 #region 名字 代码 #endregion 这样可以把代码收起来原创 2015-08-15 13:02:53 · 532 阅读 · 0 评论 -
c# 隐式转换 强制转换
隐式转换:范围小到大原创 2015-08-15 11:18:38 · 375 阅读 · 0 评论 -
C#foreach
foreach循环用于列举出集合中所有的元素,foreach语句中的表达式由关键字in隔开的两个项组成。in右边的项是集合名,in左边的项是变量名,用来存放该集合中的每个元素。 如 foreach (GameObject obj in arr) { // GameObject obj = GameObject.Find("原创 2015-06-22 14:37:34 · 540 阅读 · 0 评论 -
C# class
static 的方法和变量是 类本身的 不能通过实例化去改变 class Person { static int age; } main{ var person = new Person(); //person.age不行 Person.age = 5; }class 属性Class Perspn{ int age; public int Age{原创 2015-08-15 10:49:58 · 358 阅读 · 0 评论