This C# program demonstrates how to use the switch statement.
using System; namespace XoaX { class Program { static void Main(string[] args) { int[] siNumbers = new int[] { 0, 1, 2, 999 }; string sCreed = ""; foreach (int i in siNumbers) { sCreed = "I believe in "; switch (i) { case 0: { sCreed += "God, the Father Almighty."; break; } case 1: { sCreed += "Jesus Christ, His only son."; break; } case 2: { sCreed += "the Holy Spirit."; break; } default: { sCreed += "one, holy, catholic, and apostolic Church."; break; } } Console.WriteLine(sCreed); } } } }
I believe in God, the Father Almighty. I believe in Jesus Christ, His only son. I believe in the Holy Spirit. I believe in one, holy, catholic, and apostolic Church. Press any key to continue . . .
© 20072024 XoaX.net LLC. All rights reserved.