Arrays & Lists

Array: Fixed Size. List: Flexible

// Array - size = 3, cannot change
string[] cart = new string[3];
cart[0] = "Laptop";

// List - add/remove anytime
List<string> cart2 = new();
cart2.Add("Laptop");
cart2.Add("Mouse");
cart2.Remove("Mouse");
Rule: Use List<T> 99% of the time.

Quick Check ๐Ÿง 

Easy Q1: Can you add a 4th item to string[3]?

Comments on Arrays & Lists (0)

No comments yet. Be the first to share your thoughts!