Reversing a string:
The following code shows you how to reverse a string in both languages (C#.net and Java)
Code
In C#.net:
string strOne = "Pakistan";
char[] arr = strOne.ToCharArray();
Array.Reverse(arr);
Console.WriteLine(new string(arr));
Output:
natsikaP
In Java:
String str = "Pakistan";
StringBuffer strBuff = new StringBuffer(str);
System.out.println(strBuff.reverse());
Output:
natsikaP
0 comments:
Post a Comment