Skip to content

Commit 3d9f8ab

Browse files
authored
Create (Today)ReverseUsingLoop.cs
1 parent d4aee09 commit 3d9f8ab

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Diff for: (Today)ReverseUsingLoop.cs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Diagnostics;
3+
4+
namespace ConsoleApp18
5+
{
6+
internal static class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
const string s = "Harshal Raverkar";
11+
ReverseString(s);
12+
}
13+
14+
private static void ReverseString(string s)
15+
{
16+
var ch = s.ToCharArray();
17+
var p = ch.Length-1;
18+
19+
for (var i = 0; i < p; i++)
20+
{
21+
ch[i] ^= ch[p];
22+
ch[p] ^= ch[i];
23+
ch[i] ^= ch[p];
24+
p--;
25+
}
26+
27+
Console.WriteLine( new string(ch));
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)