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
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string str = "ganesh";
- Console.WriteLine(new string(str.Reverse().ToArray()));
- Console.WriteLine(Convert.ToString(str.Reverse().ToArray()));
- Console.WriteLine((str.Reverse().ToArray()).ToString());
- Console.ReadKey();
- }
- }
- }
- hsenag
- System.Char[]
- System.Char[]
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Sharad Lavand55 pointsPosted Jun 21, 2018, 4:52 AM EDT
protected void Button1_Click(object sender, EventArgs e) { string str = "ganesh"; string temp = new string(str.Reverse().ToArray()); // you are using overloaded method .So, need to use like this. Console.WriteLine(String.Format(new string(str.Reverse().ToArray()))); //Possiblly this will help you for printing your result. //Console.WriteLine --> there is 19 overloaded methods of "Console.WriteLine" please look into that might be help you next time. //Console.WriteLine(new string(str.Reverse().ToArray())); //Console.WriteLine(Convert.ToString(str.Reverse().ToArray())); //Console.WriteLine((str.Reverse().ToArray()).ToString()); Console.ReadKey(); }