我有一個非常簡單的問題。如果一個C++程序員可以指導我,我會非常感激。我想在C++ dll中編寫C#代碼。你能指導嗎?如何從捕獲的異常中打印消息?
C#代碼翻譯:
void someMethod{
try
{
//performs work, that can throw an exception
}
catch(Exception ex)
{
Log(ex.Message);//logs the message to a text file
}
}
//can leave this part, i can implement it in C++
public void Log(string message)
{
//logs message in a file...
}
我已經做了在C++類似的東西,但我不能嘗試{}趕上(...)的消息部分。
什麼類型的對象是你扔?它是一個'std :: exception'嗎? – Jon 2011-03-12 12:52:41
消息是'std :: exception :: what()'。 http://www.cplusplus.com/reference/std/exception/exception/ – 2011-03-12 12:58:46