• Top Posts

    Reverse a string in C#

    • In C#  Reverse String,Receives string and returns the string with its letters reversed.


     class Reverse  
       {  
         static class StringHelper  
         {  
           /// Receives string and returns the string with its letters reversed.  
           public static string ReverseString(string s)  
           {  
             char[] arr = s.ToCharArray();  
             Array.Reverse(arr);  
             return new string(arr);  
           }  
         }  
         class Program  
         {  
           static void Main()  
           {  
             Console.WriteLine(StringHelper.ReverseString("framework"));  
             Console.WriteLine(StringHelper.ReverseString("samuel"));  
             Console.WriteLine(StringHelper.ReverseString("example string"));  
             Console.ReadLine();  
           }  
         }  
       } 
    

    No comments

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728