Respublikasi oliy va o’rta maxsus ta’lim vazirligi guliston davlat universiteti amaliy matematika va
Download 1.4 Mb.
|
portal.guldu.uz-Дастурлаш технологиялари
Savollar:.NET platformasi nima. WPF qanday texnologiya. WPF arxitekturasi. AMALIY MASHG`ULOTLAR.1-Amaliy mashg’ulot Mavzu:Umumlashtirish.Umumlashgan metodlar yaratish. S# dasturni ishga tushiramiz: S# dasturni ishga tushirgan dasturdan “Sozdat proekt” bo’limini tanlaymiz: S# dasturni ishga tushirgan dasturdan “Sozdat proekt” bo’limini tanlaganimizdan keyin, Visual C# -> Windows->”Konsolnoe pridlojeniya” bo’limini tanlaymiz: ”Konsolnoe pridlojeniya” bo’limini tanlaymizdan keyin “Imya” bo’limiga o’tib Konsol pridlojeniyamizga nom beramiz: va “OK” tugmasini tanlaymiz: 1-Misol: ArrayList klass yordamida massiv elementlarni boshqarish dasturini tuzing. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace _1_AMALIY_MASHG_ULOT { class Program { static void Main(string[] args) { ArrayList alist q new ArrayList(); alist.Add("Bir"); alist.Add("Ikki"); alist.Add("To'rt"); Console.WriteLine("ArrayList dagi elementlar soni: " Q alist.Count Q " ta "); } } } Menyular satridan “OTLADKA” bo’limiga o’tamiz: Bu bo’limdan “Zapusk bez otladki” yoki klaviaturadan “CtrlQF5” tugmalarini birgalikda bosib, dasturni kompilyatsiya qilamiz. Dastur natijasi 2-Misol: ArrayList klass yordamida massiv elementlariga biror elementni qo’shish dasturini tuzing. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace _1_AMALIY_MASHG_ULOT { class Program { static void Main(string[] args) { ArrayList alist q new ArrayList(); alist.Add("Bir"); alist.Add("Ikki"); alist.Add("To'rt"); Console.WriteLine("ArrayList dagi elementlar soni: " Q alist.Count Q " ta "); G’G’ArrayList dagi elementlar soniga yangi element kiritish alist.Insert(2, "Uch"); foreach (string item in alist) { Console.WriteLine(item); } } } } Dastur natijasi Misol: ArrayList klass yordamida massiv elementlariga qo’shilgan elementni o’chirish dasturini tuzing. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace _1_AMALIY_MASHG_ULOT { class Program { static void Main(string[] args) { ArrayList alist q new ArrayList(); alist.Add("Bir"); alist.Add("Ikki"); alist.Add("To'rt"); Console.WriteLine("ArrayList dagi elementlar soni: " Q alist.Count Q " ta "); G’G’ArrayList dagi elementlar soniga yangi element kiritish alist.Insert(2, "Uch"); foreach (string item in alist) { Console.WriteLine(item); } G’G’ArrayList dagi elementdan ikkinchi elementni o'chirish alist.RemoveAt(1); foreach (string item in alist) { Console.WriteLine(item); } G’G’ArrayList dagi elementlarni tozalash alist.Clear(); foreach (string item in alist) { Console.WriteLine("G’ArrayList dagi elementlarni tozalash"); } } } } Dastur natijasi Misol: List using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace _1_AMALIY_MASHG_ULOT { class Program { static void Main(string[] args) { List G’G’Yangi ro'yhat e'lon qilish (o'lchami oldindan ko'rsatilgan): List G’G’Ro'yhat ohiriga yangi element qo'shish: list.Add(1); list.Add(3); list.Add(5); list.Add(7); list.Add(11); foreach (int son in list) { Console.WriteLine(son); } for (int i q 0; i < list.Count; iQQ) { Console.WriteLine(list[i]); } } } } Dastur natijasi Misol: List using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace _1_AMALIY_MASHG_ULOT { class Program { static void Main(string[] args) { G’G’Yangi ro'yhat e'lon qilish: List G’G’Yangi ro'yhat e'lon qilish (o'lchami oldindan ko'rsatilgan): List G’G’Ro'yhat ohiriga yangi element qo'shish: list.Add(1); list.Add(3); list.Add(5); list.Add(7); list.Add(11); foreach (int son in list) { Console.WriteLine(son); } for (int i q 0; i < list.Count; iQQ) { Console.WriteLine(list[i]); } G’G’Ro'yhat orasiga yangi elementni kiritish (indeks yordamida): list.Insert(4, 9); foreach (int son in list) { Console.WriteLine(son); } } } } Dastur natijasi Misol: List using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections; namespace _1_AMALIY_MASHG_ULOT { class Program { static void Main(string[] args) { G’G’Yangi ro'yhat e'lon qilish: List G’G’Yangi ro'yhat e'lon qilish (o'lchami oldindan ko'rsatilgan): List G’G’Ro'yhat ohiriga yangi element qo'shish: list.Add(1); list.Add(3); list.Add(5); list.Add(7); list.Add(11); foreach (int son in list) { Console.WriteLine(son); } for (int i q 0; i < list.Count; iQQ) { Console.WriteLine(list[i]); } G’G’Ro'yhat orasiga yangi elementni kiritish (indeks yordamida): list.Insert(4, 9); foreach (int son in list) { Console.WriteLine(son); } G’G’Ro'yhat elementlarini sortirovka qilish (indeks yordamida): list.Sort(); foreach (int son in list) { Console.WriteLine(son); } } } } Dastur natijasi Download 1.4 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling