Collections
List Update
A list item can be replaced by assigning through its index.
List Update
ListUpdate.cs
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
string replacement = ;
List<string> names = new List<string> { "alpha", "beta" };
names[1] = replacement;
string joined = string.Join(",", names);
Console.WriteLine($"replacement={replacement}");
Console.WriteLine($"joined={joined}");
}
}
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
string replacement = ;
List<string> names = new List<string> { "alpha", "beta" };
names[1] = replacement;
string joined = string.Join(",", names);
Console.WriteLine($"replacement={replacement}");
Console.WriteLine($"joined={joined}");
}
}
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
string replacement = ;
List<string> names = new List<string> { "alpha", "beta" };
names[1] = replacement;
string joined = string.Join(",", names);
Console.WriteLine($"replacement={replacement}");
Console.WriteLine($"joined={joined}");
}
}
indexed update
An indexed update changes the item stored at one position.