Below is the program which shows how to use foreach loop in c#.
Syntax: foreach(datatype alias in variable_to_iterate)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace File_directory_demo
{
class Program
{
static void Main(string[] args)
{
System.IO.File.Create("e:\\abc.txt");
System.IO.File.AppendAllText("e:\\abc.txt", "\n I am living in ahmednagar");
byte[] b=System.IO.File.ReadAllBytes("e:\\abc.txt");
foreach(char c in b)
{
Console.Write(c);
}
Console.ReadKey();
}
}
}
Comments
Post a Comment