In this article, we will write a C# program to convert String to Character Array in C#
class Program { static void Main(string[] args) { string value = "Welcome To Csharpstar"; // Use ToCharArray to convert string to array. char[] array = value.ToCharArray(); // Loop through array. for (int i = 0; i < array.Length; i++) { // Get character from array. char ch = array[i]; // Display each character. Console.Write("Character: "); Console.WriteLine(ch); Console.ReadLine(); } } }
Output:
Character: W
Character: e
Character: l
Character: c
Character: o
Character: m
Character: e
Character:
Character: T
Character: o
Character:
Character: C
Character: s
Character: h
Character: a
Character: r
Character: p
Character: s
Character: t
Character: a
Character: r
No comments:
Post a Comment