Arrays
Arrays
A funny Indian story that teaches arrays the way your Appa never did
When his sisters wedding was announced, he stood up, proudly held his mouse like a sword, and declared:
Each guests info was stored across the same index in all arrays. So guestNames[3] = "Uncle Ravi", and his
I am a genius.
Page 1
Arrayram and the Wedding Guest List
The arrays silently shook with fear.
Console.WriteLine($"Welcome, {guestNames[i]}!");
else
All was fine until one guest entry was blank but marked as invited. The priest bowed to a ghost. Disaster.
Lesson:
With parallel arrays, everything must stay perfectly aligned. One missing value breaks everything.
Page 2
Arrayram and the Wedding Guest List
vipList.Add(guestNames[i]);
But one wrong true value gave halwa to the wrong guest.
Lesson:
Filtering across multiple arrays is risky. All your logic depends on trusting that all indices match always.
Ravi was gone. Paati vanished too. One index shift mistake, and everything broke.
Page 3
Arrayram and the Wedding Guest List
Lesson:
Deleting in arrays means shifting values left in every array. Easy to mess up.
Lesson:
Inserting = full chaos in arrays. You must shift every value and array.
Arrayram sorted names[] alphabetically. All other arrays stayed the same.
Lesson:
Sorting one array breaks everything unless you also sort others and thats hard to maintain.
He wrote:
Page 4
Arrayram and the Wedding Guest List
for (int i = 0; i <= guestNames.Length; i++)
Lesson:
Arrays dont forgive. Looping past the last index will crash your program.
class Guest {
string Name;
bool HasInviteCard;
bool IsSpecialGuest;
bool IsFamily;
bool IsTroublemaker;
Lesson:
Use objects for real-world data. One person = one object. Easy to read, sort, filter, or delete.
Page 5
Arrayram and the Wedding Guest List
Ending
- Deleting = .Remove()
- Filtering = .Where()
- Sorting = .OrderBy()
The wedding was perfect. Everyone was happy except the ghost guest who got kicked out.
Ammas Blessing:
The End.
Page 6