這是好的,我覺得它不是正確的,就像我做一個「GOTO」,這可以嗎?可以從方法內部再次調用該方法嗎?
private void myCopySpecial()
{
TSMUI.Picker myPicker1 = new TSMUI.Picker();
Component c1 = myPicker1.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_OBJECT) as Component;
TSMUI.Picker myPicker2 = new TSMUI.Picker();
Beam fromBeam = myPicker2.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Beam;
if (c1 == null)
{
MessageBox.Show("That's not a component? Try again.");
//User selected something other than a component, start again.
myCopySpecial();
}
你想要一個StackOverflowException?因爲這就是你如何得到StackOverflowException。 – CodeCaster
這很好。它被稱爲遞歸。只要確保在某些時刻c1將會與'null'不同,否則你將得到'StackOverlowException' –
好的謝謝 - 用戶選擇c1而不是代碼,所以應該沒問題。 – gazeranco