Know the answer? Post it. Somebody with the same question will find it here.





int result = Check() ? 1 : 0;switch (grade) { case 'A': Console.WriteLine("Excellent!"); break;case 'B': Console.WriteLine("Good Job!"); break; case 'C': Console.WriteLine("Well done"); break; case 'D': Console.WriteLine("You passed"); break; case 'F': Console.WriteLine("Better try again"); break;default: Console.WriteLine("Invalid grade"); break; }
Simple way -Use switch case.
Advanced with few lines of code -Use any pattern suitable to your case .e.g -Strategy pattern



Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anil JhaRank #1,988 · 733 reputationPosted Jun 21, 2017, 8:57 PM EDT