using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
//string
string str = "Hello, How are you?";
int i = 0;
//character array declaration
char[] CH;
//converting string to character array
CH = str.ToCharArray();
//printing character array character by character
for (i = 0; i < CH.Length;i++ )
{
Console.Write(CH[i] + "");
}
Console.WriteLine();
}
}
}
Output
Hello, How are you?
In this program str is a string type variable, Using string.ToCharArray() method we copied the character of string str to CH.
And then, we are getting the length of the character array (CH) using Length property and printing character by character of CH (character array)
Consider the program:
Output
In this program str is a string type variable, Using string.ToCharArray() method we copied the character of string str to CH.
And then, we are getting the length of the character array (CH) using Length property and printing character by character of CH (character array)