How to use open file dialog for open a any file in csharp application

Today i tell how to use open file dialog in our application to open a text file ……

 before you use openfiledialog in your application you put button and text boxYou right following code in button click event.. OpenFileDialog OS = new OpenFileDialog();

           FileStream fs = new FileStream(OS.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
           StreamReader sr = new StreamReader(fs);
           sr.BaseStream.Seek(0, SeekOrigin.Begin);
           textBox1.Text = sr.ReadToEnd();

Please follow and like us:

how to use foreach loop in c sharp application

How to use foreach loop

today i will teach you how to use for each loop in c sharp application before you use for each  …For each loop  use for execute multiple statement  in one time…Syntax of for each loop ..foreach(data type var-name in expression ){
  block of statements}Example Suppose you crate a array which name is a and it range is 4 .you  want to print all the value in array you don’t want to write  multiple  statement to print value of array. so you have better option to print all value of array you use foreach loop[]a=new int[4]{10,20,30,40};

foreach(int x in a)




Please follow and like us: