我听说有很多方法可以清理代码并使其执行得更快。你能帮我清除下面的代码吗?我的程序上有很多代码,看起来像下面的代码。我还是 C# 的初学者
case "jarvis":
if (ranNum == 1) { QEvent = ""; JARVIS.Speak("Yes sir"); }
else if (ranNum == 2) { QEvent = ""; JARVIS.Speak("Yes, whats up?"); }
else if (ranNum == 3) { QEvent = ""; JARVIS.Speak("Yes, I'm here"); }
else if (ranNum == 4) { QEvent = ""; JARVIS.Speak("I'm here"); }
else if (ranNum == 5) { QEvent = ""; JARVIS.Speak("go head sir, "); }
else if (ranNum > 5) { QEvent = ""; JARVIS.Speak("I'm listening"); }
break;