This C# program is create a char array and then print the char array values using the foreach loop. The foreach loop start with first value of array and then iterate with all the values. The limitation of foreach that you can not update the array values.
using System;
namespace ConsoleHub
{
class Programs
{
static void Main(string[] args)
{
char[] CharArray = { 'm', 'n', 'o', 'p', 'q' };
foreach (char ch in CharArray)
Console.Write("->{0} ", ch);
Console.ReadLine();
}
}
}
No comments:
Post a Comment