public void setClassVar(MyObj obj) { if (obj == null) { obj = new MyObj(777); } }
public static void Test() { MyClass m = new MyClass(111); MyObj o = null; MyObj o2 = new MyObj(999); trySet(m); Console.WriteLine("result=" + m.val); m.setClassVar(o); m.setClassVar2(o2); Console.WriteLine(o); int[] a = null; trySet2(a); Console.WriteLine(String.Join(",", a)); int[] a2 = new int[] { 1, 2, 3, 4 }; trySet3(a2); Console.WriteLine(String.Join(",", a2)); }
public void setClassVar2(MyObj obj) { this.obj = obj; }