linq metodlari bilan ishlash

DOCX 3 pages 17.8 KB Free download

Page preview (3 pages)

Scroll down 👇
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

Want to read more?

Download all 3 pages for free via Telegram.

Download full file

About "linq metodlari bilan ishlash"

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...

This file contains 3 pages in DOCX format (17.8 KB). To download "linq metodlari bilan ishlash", click the Telegram button on the left.

Tags: linq metodlari bilan ishlash DOCX 3 pages Free download Telegram