1- misol. uqish.txt fayldan ikkita sonni o’qib, ularni yig’indisini yozish.txt fayliga yozish dasturini ko’rib chiqamiz.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication1
{ class Program
{ static void Main(string[] args)
{
StreamWriter yozish = new StreamWriter("d:\\yozish.txt");
StreamReader uqish = new StreamReader("d:\\uqish.txt"); yozish.WriteLine(int.Parse(uqish.ReadLine()) + int.Parse(uqish.ReadLine())); yozish.Close(); uqish.Close();
} } }
Dastur natijasi: dasturni ishlatishdan oldin uqish.txt faylda 2 ta son kiritish kerak, so’ng dastur ikkita sonni o’qib, ularni yig’indisini yozish.txt fayliga yozadi. Natijani ko’rish uchun yozish.txt faylni ochib ko’rish kerak
Do'stlaringiz bilan baham: |