Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The below program will help you to initialize the char array. While defining the

ID: 3769858 • Letter: T

Question

The below program will help you to initialize the char array. While defining the array you can pass the set of value to directly initialize it. The for loop is used here to print the char array values.

A B C D E

using System;

namespace ConsoleHub

{

class Programs

{

static void Main(string[] args)

{

char[] CharArray = { 'A', 'B', 'C', 'D', 'E' };

for (int i = 0; i < CharArray.Length; i++)

Console.Write(" {0}", CharArray[i]);

Console.ReadLine();

}

}

}

Project :

Create a program that initialize a Char array and print it. The array will be entered from the console.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
namespace ConsoleHub
{
class Programs
{
static void Main(string[] args)
{
//char[] CharArray = { 'A', 'B', 'C', 'D', 'E' };
Console.WriteLine("Enter String");
String s= Console.ReadLine();
char[] CharArray =s.ToCharArray ();
for (int i = 0; i < CharArray.Length; i++)
Console.Write(" {0}", CharArray[i]);
Console.ReadLine();
}
}
}