摘要: public partial class People : MonoBehaviour { } public partial class People { } 对一个类进行拆分,用于并行开发,但定义的参数和函数名不能重复。 阅读全文
posted @ 2022-11-12 12:56 坞中客 阅读(13) 评论(0) 推荐(0) 编辑
摘要: void Start() { // 作为可变参数进行产地 Debug.Log(Sum(1, 2, 3)); // 作为数组进行传递 Debug.Log(Sum1(new int[] { 1, 2, 3 })); } // 可变参数 public int Sum(params int[] a) { i 阅读全文
posted @ 2022-11-12 12:54 坞中客 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 值传递:把数值传进入,自己不进去。 引用传递:把自己传到函数内存去。 void Start() { int a = 0; Add(ref a); Sub(out a); } void Add(ref int a) { } void Sub(out int a) { a = 0; } ref和out的 阅读全文
posted @ 2022-11-12 12:53 坞中客 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 在不修改原始代码的情况下添加新的成员方法(只能添加成员方法) 如:给数组添加一个求和功能 public static class ExtArray { public static double Sum(this Array o) { double sum = 0; foreach (var item 阅读全文
posted @ 2022-11-12 12:52 坞中客 阅读(19) 评论(0) 推荐(0) 编辑