SHARE
TWEET

Read20Chars.cs

a guest Feb 1st, 2013 33 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class Read20Chars
  4. {
  5.     static void Main()
  6.     {
  7.         try
  8.         {
  9.             Console.Write("Enter word not more than 20 chars long: ");
  10.             string input = Console.ReadLine();
  11.  
  12.             if (input.Length > 20) throw new IndexOutOfRangeException();
  13.             else Console.WriteLine(input += new string('*', 20 - input.Length));
  14.         }
  15.         catch (IndexOutOfRangeException)
  16.         {
  17.             Console.WriteLine("String too long!");
  18.         }
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top