What is the difference between the code below? Both methods achieve the same output of removing 4 from the list.
static void Main(string[] args)
{
var list = new List<int> {1, 2, 3, 4, 5, 6, 7, 8, 9};
ModifyList(ref list);
Console.WriteLine(string.Join(", ", list));
list.Add(4);
ModifyList(list);
Console.WriteLine(string.Join(", ", list));
Console.ReadLine();
}
public static void ModifyList(ref List<int> list)
{
list.Remove(4);
}
public static void ModifyList(List<int> list)
{
list.Remove(4);
}