Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ArrayGame
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] games = { "Alien Shooter", "Tic Tac Toe", "Snake", "Puzzle", "Football" };
- string input = Console.ReadLine();
- // Convert input to integer
- if (int.TryParse(input, out int index))
- {
- // Check if index is within valid range
- if (index >= 1 && index <= games.Length)
- {
- // Display the game at the specified index
- Console.WriteLine(games[index]);
- }
- else
- {
- Console.WriteLine("Nomor game tidak valid.");
- }
- }
- else
- {
- Console.WriteLine("Input tidak valid. Harap masukkan angka.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment