svetlozar_kirkov

Pad short string (Exercise)

Oct 10th, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace ConsoleTests
  5. {
  6.     class ConsoleTests
  7.     {
  8.         static void Main()
  9.         {
  10.             string input;
  11.             bool isValid;
  12.             do
  13.             {
  14.                 Console.Write("Enter string (20 characters max): ");
  15.                 input = Console.ReadLine();
  16.                 isValid = input.Length > 0 && input.Length <= 20;
  17.                 if (isValid == false)
  18.                 {
  19.                     Console.WriteLine("Invalid string");
  20.                 }
  21.             } while (isValid == false);
  22.             Console.WriteLine("Result: {0}",input.PadRight(20,'*'));
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment