Примеры кода

Продвинутая работа с массивами

Сортировка (пузырьковый метод)

static void BubbleSort(int[] arr)
{
    int temp;
    for (int i = 0; i < arr.Length; i++)
    {
        for (int j = 0; j < arr.Length - 1; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
            }
        }
    }
}

Удаление элемента по индексу (со сдвигом)

static int[] RemoveAt(int[] source, int index)
{
    int[] dest = new int[source.Length - 1];
    if (index > 0)
        Array.Copy(source, 0, dest, 0, index);

    if (index < source.Length - 1)
        Array.Copy(source, index + 1, dest, index, source.Length - index - 1);

    return dest;
}

Фильтрация четных чисел (LINQ)

using System.Linq;

int[] numbers = { 1, 2, 3, 4, 5, 6 };
int[] evenNumbers = numbers.Where(n => n % 2 == 0).ToArray();

// Результат: 2, 4, 6