Arrays in C#
Në shqip: Vargjet në C#
ShpjegimiSQ
Një varg në C# ka madhësi të fiksuar dhe elemente të të njëjtit tip: int[] notat = { 5, 4, 3 };. Ndryshe nga C-ja, C#-i e di gjatësinë (.Length) dhe të ndal me gabim po dole jashtë kufijve.
EnglishEN
An array in C# has a fixed size and items of the same type: int[] grades = { 5, 4, 3 };. Unlike C, C# knows its length (.Length) and stops you with an error if you go out of bounds.
Si ta mendosh
Si kutia e vezëve me 10 vende — por me një roje që të ndal po provove ta fusësh të 11-tën.
Lexoje në anglisht
Like an egg box with 10 slots — but with a guard who stops you if you try to put in an 11th.
Shembull kodicsharp
int[] notat = { 5, 4, 3 };
Console.WriteLine(notat.Length); // 3
Console.WriteLine(notat[^1]); // 3 (i fundit)