我有這樣的問題:無法到達的代碼檢測到的字符串Speech = e.Result.Text;
http://s28.postimg.org/x8gb3pvkb/Capture.png 這是谷歌的搜索代碼通過語音:
string Speech = e.Result.Text;
if (Speech == "I WANT TO SEARCH SOMETHING")
{
QEvent = Speech;
JARVIS.SpeakAsync("what do you want to search");
Speech = string.Empty;
}
else if (Speech != string.Empty && QEvent == "I WANT TO SEARCH SOMETHING")
{
System.Diagnostics.Process.Start("http://google.com/search?q=" + Speech);
QEvent = string.Empty;
ranNum = rnd.Next(1, 4);
if (ranNum == 1) { JARVIS.SpeakAsync("Alright, I am searching " + Speech + " in google"); }
else if (ranNum == 2) { JARVIS.SpeakAsync("ok sir, I am searching " + Speech); }
else if (ranNum == 3) { JARVIS.SpeakAsync("Alright, I am searching "); }
Speech = string.Empty;
}
而且在錯誤列表中顯示我這個錯誤:
Unreachable code Detected
你能告訴我爲什麼這個是無法訪問的代碼?
什麼行是錯誤? – box86rowh 2014-10-19 13:30:35
啊,看到了截圖,你必須在你粘貼的代碼之前關閉開關。 – box86rowh 2014-10-19 13:32:13
你忘了用'}關閉你的'switch' – Rotem 2014-10-19 13:32:22