Venciity

[Jumpstart C#] Console Demos - Reading Strings

Jan 22nd, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. class ReadingStrings
  5. {
  6.     static void Main()
  7.     {
  8.         //if Unicode is not specified , it will read ASCII
  9.         //Works on .NET Framework 4.0 and above
  10.         Console.InputEncoding = Encoding.Unicode;
  11.         Console.OutputEncoding = Encoding.Unicode;
  12.  
  13.         Console.Write("Please enter your first name: ");
  14.         string firstName = Console.ReadLine();
  15.         Console.Write("Please enter your last name: ");
  16.         string lastName = Console.ReadLine();
  17.         Console.WriteLine("Hello, {0} {1} !", firstName, lastName);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment