Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //Write a program that reads a string, reverses it and prints the result at the console.
- //Example: "sample" "elpmas".
- class Problem2ReverseString
- {
- static string Reversed(string text)
- {
- StringBuilder build = new StringBuilder();
- for (int i = text.Length - 1; i >= 0; i--)
- {
- build.Append(text[i]);
- }
- return build.ToString();
- }
- static void Main()
- {
- string text = "hello";
- string reversed = Reversed(text);
- Console.WriteLine(reversed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement