Lists: // are like array but flexible. arrays are fixed lengths while list can be flexible with adding and removing. List Declaring: List<dataType> variableName = new List<dataType>(); // initialize empty list List<int> variableName = new List<int>{5,1,3,5,3}; // initializes a filled list List Indexing: // Same as array listName[0]; List Methods: Add() Method: listVariable.Add(newValueToAdd); // adds a new value to the list at the end of the list Count Method: listVariable.Count; // returns the length of the list Insert() Method: listVariable.Insert(index, value); // inserts a value at a specified location, moving other values up/down to make space Remove() Method: listVariable.Remove(value); // removes the FIRST appearance of a value from the list RemoveAt() Method: listVariable.RemoveAt(index); // removes the value at the specified index Contains() Method: listVariable.Contains(valueToSearch); // returns true or false if found Clear() Method: listVariable...
Comments
Post a Comment