這是統一C#如何正確使用信息:System.InvalidOperationException
//...
public static void Interupt(int Index, string Text){
try{
Change(Transforms[ Index ], Text);
}
catch{
throw new System.InvalidOperationException("Index: " + Index + " Is too large should be less than: " + Transforms.Count); // points me here
}
}
}
確定該代碼指向我
throw, ...
我怎麼讓它指向我行,其中調用該函數?
,如:
using UnityEngine;
using System.Collections;
public class TestScript : MonoBehaviour {
void Start(){
SomeClass.Interupt(5, ""); // I want it to point me here
}
}
THO我也嘗試這樣做:
return throw new System.InvalidOperationException("Index: " + Index + " Is too large should be less than: " + Transforms.Count);
,但我得到:
error CS1525: Unexpected symbol `throw'
女巫是完全合乎邏輯的。
但我無法弄清楚是怎麼處理這個事情,它指向我們的功能,而不是拋出線?
我希望任何人都有在Unity引擎
您需要讀取整個堆棧跟蹤。另外,不要吞下原始異常;你隱藏了關於實際問題的所有信息。 http://stackoverflow.com/a/2999314/34397 – SLaks
hmmm @Slaks如果我用throw new進行隱藏,...我如何將它指向函數女巫調用它而不是異常行? – MilitaryG