0
How do you convert string to Char Array in C#?
I tried with the ToCharArray method but it seems it doesn't work
8 Answers
+ 1
There must be a function for that.. May be syntax issue with your ToCharArray().
But otherthan, as a temporary solution, as simple alternative also you can use foreach loop, like
foreach (var ss in stringA)
s[i++]=ss;
Here, stringA is string
s[] is char array..
Edit:
Yes. It also works
string sentence = "hello world";
char[] cArray= sentence.ToCharArray();
foreach (char ch in cArray)
Console.WriteLine(ch);
+ 1
~ swim ~ i was trying this for a code coach but i'll try it with your code now
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
string s = "Hello World";
s.ToCharArray();
Array.Reverse(s);
Console.WriteLine(s);
}
}
}
+ 1
Ohh you're right now it works
https://code.sololearn.com/cv58uZsa4c7p/?ref=app
+ 1
Use ToCharArray() or string.Split() function
0
AI-Virar does String.Split() exist in C#?
0
HadexGM yes it does