SHARE
TWEET

ReverseString

PolinaKoleva Feb 1st, 2013 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. //Write a program that reads a string, reverses it and prints the result at the console.
  6. //Example: "sample"  "elpmas".
  7.  
  8. class Problem2ReverseString
  9. {
  10.     static string Reversed(string text)
  11.     {
  12.         StringBuilder build = new StringBuilder();
  13.         for (int i = text.Length - 1; i >= 0; i--)
  14.         {
  15.             build.Append(text[i]);
  16.         }
  17.         return build.ToString();
  18.     }
  19.     static void Main()
  20.     {
  21.         string text = "hello";
  22.         string reversed = Reversed(text);
  23.         Console.WriteLine(reversed);
  24.     }
  25. }
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