考虑以下代码C#代码。是否执行“最终”块?
public void DoesThisExecute() { string ext = "xlsx"; string message = string.Empty; try { switch (ext) { case "xls": message = "Great choice!"; break; case "csv": message = "Better choice!"; break; case "exe": message = "Do not try to break me!"; break; default: message = "You will not win!"; return; } } catch (Exception) { // Handle an exception. } finally { MessageBox.Show(message); } }
哈,写完这些之后,我意识到自己可以在Visual Studio中自己测试一下。但是,请随时回答!
是的,它确实是:-) http://msdn.microsoft.com/zh- cn/library/zwc8s4fz.aspx