{"record":{"id":"cb24d2cafab8dd88","repo":"krahets/hello-algo","slug":"error-cb24d2","errorCode":null,"errorMessage":"индекс выходит за границы","messagePattern":"индекс выходит за границы","errorType":"exception","errorClass":"IndexOutOfRangeException","httpStatus":null,"severity":"error","filePath":"ru/codes/csharp/chapter_array_and_linkedlist/my_list.cs","lineNumber":35,"sourceCode":"    public MyList() {\n        arr = new int[arrCapacity];\n    }\n\n    /* Получить длину списка (текущее число элементов) */\n    public int Size() {\n        return arrSize;\n    }\n\n    /* Получить вместимость списка */\n    public int Capacity() {\n        return arrCapacity;\n    }\n\n    /* Доступ к элементу */\n    public int Get(int index) {\n        // Если индекс выходит за границы, выбрасывается исключение; далее аналогично\n        if (index < 0 || index >= arrSize)\n            throw new IndexOutOfRangeException(\"индекс выходит за границы\");\n        return arr[index];\n    }\n\n    /* Обновление элемента */\n    public void Set(int index, int num) {\n        if (index < 0 || index >= arrSize)\n            throw new IndexOutOfRangeException(\"индекс выходит за границы\");\n        arr[index] = num;\n    }\n\n    /* Добавление элемента в конец */\n    public void Add(int num) {\n        // При превышении вместимости по числу элементов запускается расширение\n        if (arrSize == arrCapacity)\n            ExtendCapacity();\n        arr[arrSize] = num;\n        // Обновить число элементов\n        arrSize++;","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/krahets/hello-algo/blob/69932aed1891a7b7f6a0de88cd116d3fe13e7032/ru/codes/csharp/chapter_array_and_linkedlist/my_list.cs#L17-L53","documentation":"IndexOutOfRangeException with message \"индекс выходит за границы\" (Russian for \"index out of bounds\") is thrown by MyList.Get(int index) when index < 0 or index >= arrSize. The logic is identical to the English version; only the message string differs.","triggerScenarios":"Calling Get(index) where index < 0 or index >= list.Size(). An empty MyList (arrSize 0) throws for any index including 0.","commonSituations":"Off-by-one iteration bounds, reading from an unpopulated list, or using an externally-supplied index without validation. Russian-speaking developers may search for the localized message.","solutions":["Validate 0 <= index < list.Size() before calling Get().","Correct loop bounds to i < Size().","Clamp or reject indices from external input."],"exampleFix":"// before\nMyList list = new();\nlist.Add(10);\nint val = list.Get(1); // throws\n\n// after\nif (index >= 0 && index < list.Size())\n    int val = list.Get(index);","handlingStrategy":"validation","validationCode":"if (index >= 0 && index < list.Size()) {\n    int val = list.Get(index);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int val = list.Get(index);\n} catch (IndexOutOfRangeException ex) when (ex.Message.Contains(\"выходит за границы\")) {\n    // handle out-of-bounds\n}","preventionTips":["Use i < list.Size() in loops, never i <= list.Size().","Validate external indices before passing to Get().","When catching by message, match \"индекс выходит за границы\"."],"tags":["csharp","array","index-out-of-bounds","precondition","list","russian","i18n"],"backgroundTag":null,"analyzedSha":"69932aed1891a7b7f6a0de88cd116d3fe13e7032","analyzedAt":"2026-08-13T23:02:37.581Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}