Ganesamoorthi M

Ganesamoorthi M

  • NA
  • 129
  • 1.4k

Convert.ToString() vs ToString() vs new string()

Jun 21 2018 7:06 AM
I am doing string reverse while I have some problem with that. I have added code and O/P below. Please give me the detail explanation for this solution. I am beginner in C#. 
 
CODE
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5.   
  6. namespace ConsoleApplication1  
  7. {  
  8.     class Program  
  9.     {  
  10.         static void Main(string[] args)  
  11.         {  
  12.             string str = "ganesh";  
  13.             Console.WriteLine(new string(str.Reverse().ToArray()));  
  14.             Console.WriteLine(Convert.ToString(str.Reverse().ToArray()));  
  15.             Console.WriteLine((str.Reverse().ToArray()).ToString());  
  16.             Console.ReadKey();  
  17.         }  
  18.     }  
  19. }  
  OUTPUT
  1. hsenag  
  2. System.Char[]  
  3. System.Char[]  
 

Answers (1)