我多次运行我的方法两次,因为在运行它们之前检查它们的返回值,我想知道是否有一种方法可以防止这种情况,比如使用我要检查的方法返回的值。很难解释,所以这里是我的程序中的一个真实的例子。if (Domain.SF.SF.GetOrder(WorkOrd) != null) //If the value is not null (My method returns null if
一切都很好,但是当我调用第二个方法时,我总是得不到任何结果,并且我得到了一个试图拆箱空值(NullReferenceException)的异常。 IL_0092: nop **\\And i get a Exception here because loc 4 is nullunbox.any [mscorlib]System.Int32} // end of method TestClassP
也就是说,让一个类方法递归并最终返回一个对象?当我运行递归方法时,如果它至少递归了一次,它总是返回null……// some class method // look at its own collection在某个其他类中或在main中:// if rock thrower has had to recurse