linq metodlari bilan ishlash

DOCX 3 sahifa 17,8 KB Bepul yuklash

Sahifa ko'rinishi (3 sahifa)

Pastga aylantiring 👇
1 / 3
1. string[] people = { "tom", "tim", "bob", "sam" }; // проверяем, все ли элементы имеют длину в 3 символа bool allhas3chars = people.all(s => s.length == 3); // true console.writeline(allhas3chars); // проверяем, все ли строки начинаются на t bool allstartswitht = people.all(s => s.startswith("t")); // false console.writeline(allstartswitht); 2. string[] people = { "tom", "tim", "bob", "sam" }; // проверяем, все ли элементы имеют длину больше 3 символов bool allhasmore3chars = people.any(s => s.length > 3); // false console.writeline(allhasmore3chars); // проверяем, все ли строки начинаются на t bool allstartswitht = people.any(s => s.startswith("t")); // true console.writeline(allstartswitht); 3. string[] people = { "tom", "tim", "bob", "sam" }; // проверяем, есть ли строка tom bool hastom = people.contains("tom"); // true console.writeline(hastom); // проверяем, есть ли строка mike bool hasmike = people.contains("mike"); // false console.writeline(hasmike); 4. string[] people = { "tom", "tim", "bob", "sam" }; // проверяем, есть ли строка tom bool hastom …
2 / 3
var first = people.firstordefault(); // tom console.writeline(first); // первая строка, длина которой равна 4 символам var firstwith4chars = people.firstordefault(s => s.length == 4); // kate console.writeline(firstwith4chars); // первый элемент из пустой коллекции var firstordefault = new string[] {}.firstordefault(); console.writeline(firstordefault); // null 9. string[] people = { "tom", "bob", "kate", "tim", "mike", "sam" }; string? firstwith5chars = people.firstordefault(s => s.length == 5, "undefined"); console.writeline(firstwith5chars); // undefined // первый элемент из пустой коллекции строк string? firstordefault = new string[] {}.firstordefault("hello"); // hello - значение по умолчанию console.writeline(firstordefault); // hello // первый элемент из пустой коллекции int int firstnumber = new int[] {}.firstordefault(100); // 100 - значение по умолчанию console.writeline(firstnumber); // 100 10. string[] people = { "tom", "bob", "kate", "tim", "mike", "sam" }; string last = people.last(); console.writeline(last); // sam string lastwith4chars = people.last(s => s.length == 4); console.writeline(lastwith4chars); // mike 11. string[] people = { "tom", "bob", "kate", "tim", "mike", "sam" …
3 / 3
linq metodlari bilan ishlash - Page 3

Ko'proq o'qimoqchimisiz?

Barcha 3 sahifani Telegram orqali bepul yuklab oling.

To'liq faylni yuklab olish

"linq metodlari bilan ishlash" haqida

1. string[] people = { "tom", "tim", "bob", "sam" }; // проверяем, все ли элементы имеют длину в 3 символа bool allhas3chars = people.all(s => s.length == 3); // true console.writeline(allhas3chars); // проверяем, все ли строки начинаются на t bool allstartswitht = people.all(s => s.startswith("t")); // false console.writeline(allstartswitht); 2. string[] people = { "tom", "tim", "bob", "sam" }; // проверяем, все ли элементы имеют длину больше 3 символов bool allhasmore3chars = people.any(s => s.length > 3); // false console.writeline(allhasmore3chars); // проверяем, все ли строки начинаются на t bool allstartswitht = people.any(s => s.startswith("t")); // true console.writeline(allstartswitht); 3. string[] people = { "tom", "tim", "bob", "sam" }; // проверяем, есть ли строка tom bool hast...

Bu fayl DOCX formatida 3 sahifadan iborat (17,8 KB). "linq metodlari bilan ishlash"ni yuklab olish uchun chap tomondagi Telegram tugmasini bosing.

Teglar: linq metodlari bilan ishlash DOCX 3 sahifa Bepul yuklash Telegram