Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Accept a string from keyboard and print it

C# Sharp String: Exercise-1 with Solution

Write a program in C# Sharp to input a string and print it.

C# Sharp Exercises: Accept a string from keyboard and print it.

Sample Solution:-

C# Sharp Code:

using System;  
public class Exercise1 
{
    public static void Main()  
   {  
	    string str;
	
    Console.Write("\n\nAccept a string from keyboard :\n");
    Console.Write("-----------------------------------\n"); 	
    Console.Write("Input the string : ");
    str= Console.ReadLine();
    Console.Write("The string you entered is : {0}\n", str);
	}
}

Sample Output:

Accept a string from keyboard :                                        
-----------------------------------                                    
Input the string : w3resource is very easy tutorial.                   
The string you entered is : w3resource is very easy tutorial.

Flowchart:

Flowchart: Accept a string from keyboard

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: C# Sharp String Exercise.
Next: Write a program in C# Sharp to find the length of a string without using library function.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.