Created
September 8, 2024 10:27
-
-
Save SGudbrandsson/6869216dc86146d4aa24ada1b014857e to your computer and use it in GitHub Desktop.
C# Lists Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<int> grades = new List<int> { 85, 90, 78, 92 }; | |
Console.WriteLine("Grades: " + string.Join(", ", grades)); | |
grades.Add(88); // Adding a new grade | |
Console.WriteLine("Grades: " + string.Join(", ", grades)); | |
int highestGrade = grades[3]; // Accessing the grade at index 3 | |
grades.RemoveAt(2); // Removing the grade at index 2 (which is 78) | |
Console.WriteLine("Grades: " + string.Join(", ", grades)); | |
Console.WriteLine($"Highest grade: {highestGrade}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment