+92 332 4229 857 99ProjectIdeas@Gmail.com

How to reverse a string (C#.net Vs Java)


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: