How to write a program in C# like a mini-game ?

Total Post:46

Points:324

C#  OOPS 
C#
 505  View(s)
Ratings:
Rate this:

write a program something like a game...any type 

  1. Re: How to write a program in C# like a mini-game ?

    using System;
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication17
    {
        class Program
        {
            static void Main(string[] args)
            {
                while (true)
                {
                    int rdmNum = snt(1, 51);
                    int count = 1;
                    while (true)
                    {
                        Console.Write("Please put a numerical value here between 1 and 50(0 to quit):");
                        int input = Convert.ToInt32(Console.ReadLine());
                        if (input == 0)
                            return;
                        else if (input < rdmNum)
                        {
                            Console.WriteLine("Sorry, This value is Low \nPlease try again...");
                            ++count;
                            continue;
                        }
                        else if (input > rdmNum)
                        {
                            Console.WriteLine("Sorry, This value is High \nPlease try again.");
                            ++count;
                            continue;
                        }
                        else
                        {
                            Console.WriteLine("Hi, You guessed this! The number was {0}!", rdmNum);
                            Console.WriteLine("It found you {0} {1}.\n", count, count == 1 ? "try" : "tries");
                            break;
                        }
                    }
                }
            }
            static int snt(int min, int max)
            {
                Random random = new Random();
                return random.Next(min, max);
            }
        }
    }

    How to write a program in C# like a mini-game ?

    How to write a program in C# like a mini-game ?

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.