O`zbekiston milliy universiteti


Download 160.38 Kb.
Sana09.06.2023
Hajmi160.38 Kb.
#1469462
Bog'liq
Algaritmik tillar





MIRZO ULUG`BEK NOMIDAGI
O`ZBEKISTON MILLIY UNIVERSITETI
JIZZAX FILIALI

Amaliy matematika va informatika fakulteti


“Kompyuter ilmlari va dasturlash texnologiyalari” yo`nalishi:
ALGARITMIK TILLAR VA DASTURLASH ASOSLARI fanidan

MUSTAQIL ISH



Mavzu: 2-Modul topshiriq
Bajardi: Yunusov.H.
Tekshirdi: Kayumov.O.
Jizzax 2021

2-Modul topshiriq
29-variant
1-topshiriq Savollar.
#9 Matn fayliga matn qo'shish quyidagi kodlar yordamida amalga oshiriladi:

string textToWrite = "Matn fayliga yozilgan matn";


string filePath = @"C:\Users\user\Desktop\test.txt";

using (StreamWriter writer = new StreamWriter(filePath, true))


{
writer.WriteLine(textToWrite);
}
Bu yordamda StreamWriter sinfi matn faylini yarata oladi va yozish yoki yozgan ma'lumotni saqlash uchun faylni nomini ham olib keladi.
2-topshiriq Berilganlar oqimi.
using System.Xml;
class Program {
static void Main(string[] args) {
var reader = XmlReader.Create("example.xml");
while (reader.Read()) {
if (reader.IsStartElement()) {
switch (reader.Name) {
case "talaba":
var talaba = new Talaba();
talaba.Id = int.Parse(reader.GetAttribute("id"));
talaba.Name = reader.GetAttribute("name");
break;
case "address" when talaba != null:
var address = new Address();
address.Street = reader.GetAttribute("street");
address.City = reader.GetAttribute("city");
talaba.Addresses.Add(address);
break;
}
}
}
}
}


3-topshiriq Fayl tizimi bilan ishlash:
using System.IO;

string filePath = @"fayl adresi";


DirectoryInfo parentDirectory = Directory.GetParent(filePath);


Console.WriteLine("Parent directory of {0} is {1}", filePath, parentDirectory.FullName);




Bunda:
Directory.GetParent usulidan foydalanib faylning asosiy katalogini oldim.
Bundan tashqari:
string rootDirectory = Path.GetPathRoot(Environment.SystemDirectory);orqali ham amalga oshirsa bo`ladi.
Foydalanilgan malumotlar.
https://www.w3schools.com/cs/index.php
dan o`rganildi.
Download 160.38 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling