Sunday, April 23, 2017

Input/Output C#

Part #2:
Topic : Take value form user and show.

Today we will write a program which able to get data from user and when execute the program it take data from user and the data value will show at console.

Select a new project the select console application and project name like 'IOApp'. Then OK.
Write the following code in to the program class-

        static void Main(string[] args)
        {
            Console.Write("Enter your name: ");
            string input=Console.ReadLine();
            Console.WriteLine("Your name is: "+input);
            Console.ReadKey();
        }


Now build and run your solution.

Enter your name: Code All Time

Press Enter

Your name is: Code All Time

Note: In c# language to get data use Console.Read and to display data use Console.Write

No comments:

Post a Comment