51
1
using System;
2
using System.Text;
3
4
public class Program
5
{
6
// How many ways can you write to reverse a string in C#?
7
8
public static void Main()
9
{
10
string str = "I am in Coffs harbour";
11
12
Console.WriteLine(str.Reverse());
13
Console.WriteLine(str.Reverse2());
14
Console.WriteLine(str.Reverse3());
15
}
16
}
17
18
public static class StringEx
19
{
20
public static string Reverse(this string str)
21
{
22
int strLen = str.Length;
23
char[] arr = new char[strLen];
24
int arrIndex = 0;
Cached Result
Hi, Mr Pirzada
-------------------Separator---------------------
12345678
-------------------Separator---------------------
12345678