Locked lesson.
About this lesson
Appending Arrays in C# is a bit different than in other programming languages.
Exercise files
Download this lesson’s related exercise files.
25 - Appending Arrays.docx61.1 KB 25 - Appending Arrays SOLUTION.docx
58.2 KB
Quick reference
Appending Arrays
Arrays may be appended when you want to add something to the end.
When to use
Use this method to append an array.
Instructions
using System.Linq;
string[] toppings = new string[3] {"Pepperoni", "Mushroom", "Onion"};
toppings = toppings.Append("Green Peppers").ToArray();
Console.WriteLine(toppings[3]);
Hints & tips
- Don't forget to import: using System.Linq;
- toppings = toppings.Append("Green Peppers").ToArray();
Lesson notes are only available for subscribers.