Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

reverse string without using any C# function

$
0
0

hi

i want to reverse string just like

input is "My Name is Khan"

output is "Khan is Name My"

my function is

public sring reverse()

{

string str=" my name is khan";

string str1=string.empty;

string[] strArr=str.split(' ');

for (int i=strArr.length; i>0; i--)

{

str1=str1+strArr[i]+" ";

}

return str1;

}

this is right function to reverse string  as i want

i don't to use split function as we used in my code str.split(' ');

so please give me logic how we can reverse a string without using split function

thanks in advance 


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>