Advertisement
Guest User

02. String Length

a guest
May 13th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class StringLength
  8. {
  9.     static void Main()
  10.     {
  11.         string input = Console.ReadLine();
  12.         int inputLength = input.Length;
  13.  
  14.         if (inputLength < 20)
  15.         {
  16.             int lengthToTwenty = 20 - inputLength;
  17.             string additionSymbols = new string('*', lengthToTwenty);
  18.             Console.WriteLine("{0}", input + additionSymbols);
  19.         }
  20.         else
  21.         {
  22.             string exactTwenty = input.Substring(0, 20);
  23.             Console.WriteLine(exactTwenty);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement