SHARE
TWEET

Untitled

a guest Jun 20th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         //string format
  8.         /*
  9.         Console.WriteLine("Enter a number: ");
  10.         int number = int.Parse(Console.ReadLine());
  11.         Console.WriteLine("normal: {0}",number);
  12.         Console.WriteLine("currency: {0:c}",number);
  13.         Console.WriteLine("whole: {0:d}",number);
  14.         Console.WriteLine("3 decimal digits: {0:f3}",number);
  15.         Console.WriteLine("percentage: {0:p}",number);
  16.         Console.WriteLine("hexadecimal: {0:x}",number);
  17.         */
  18.        
  19.         //string reversal
  20.         Console.WriteLine("Please enter some text to reverse it: ");
  21.         string text = Console.ReadLine();
  22.         char[] reverseText = new char[text.Length];
  23.        
  24.         for(int counter = 0; counter < text.Length;counter++)
  25.         {
  26.             reverseText[text.Length - 1 - counter] = text[counter];
  27.         }
  28.         Console.WriteLine("Input: ");
  29.         Console.WriteLine(text);
  30.         Console.WriteLine("Reversed: ");
  31.         Console.WriteLine(reverseText);
  32.     }
  33. }
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