.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Random number will display text.

Posted By:laptop charles       Posted Date: October 30, 2010    Points: 15    Category: Visual Studio    URL: http://www.dotnetspark.com  

Random generation concept is used to print the random number in digit to text.
 

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

namespace Randomnumber
{
    class Program
    {
        static void Main(string[] args)
        {
            int c = new System.Random().Next(5);

            if (c ==0)
            {
                Console.WriteLine("Zero");
            }
            else if (c == 1)
            {
                Console.WriteLine("One");
            }
            else if (c == 2)
            {
                Console.WriteLine("Two");
            }
            else if (c == 3)
            {
                Console.WriteLine("Three");
            }
            else

            {
                Console.WriteLine("Four");
            }

            Console.ReadLine();
        }
    }
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend