BasicKnowledgeCSharp/LessonsAndTasks/Lesson 27 - Как работать с массивами на самом деле/Program.cs
Dvurechensky bf6a7c2b4e 1.1
2025-05-12 02:48:54 +03:00

34 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Author: Nikolay Dvurechensky
* Site: https://www.dvurechensky.pro/
* Gmail: dvurechenskysoft@gmail.com
* Last Updated: 12 мая 2025 02:47:11
* Version: 1.0.3
*/
using System;
using System.Linq;
/*
* как работать с массивами на самом деле
*/
class Program
{
static void Main()
{
int[] myArray = { 111, 10, 4, 99, 49, 64, 99, 4, 42, 5 };
int value_0 = myArray.Min();
int[] value_1 = myArray.Where(i => i % 2 != 0).ToArray(); //Перебор по нужному условию
Console.WriteLine(value_1);
int[] result = myArray.Distinct().ToArray(); //Только уникальные
int[] result_1 = myArray.OrderBy(i => i).ToArray(); //Сортировка
Array.Sort(myArray);
Array.Find(myArray, i => i < 70);
Array.FindLast(myArray, i => i < 70);
int[] result_2 = Array.FindAll(myArray, i => i < 70);
int result_3 = Array.FindIndex(myArray, i => i == 70);
Array.Reverse(myArray);
int result_4 = myArray.Where(i => i < 70).FirstOrDefault(); //Первое число меньше 70
Console.ReadKey();
}
}