59
1
using System;
2
using System.Collections.Generic;
3
namespace ListCSharpExample
4
{
5
6
public class ListCSharpExample
7
{
8
9
public static void Main()
10
{
11
12
// List initialization and adding elements to the end of the list:
13
List<char> lst = new List<char> { 'a', 'b', 'c' };
14
15
//add new elements in lst
16
lst.Add('d');
17
lst.Add('e');
18
ShowList("Initial list, followed by lst.Add('d'); lst.Add('e');", lst);
19
20
// Insert and push towards the end
21
lst.Insert(0, 'n');
22
ShowList("lst.Insert(0,'n');", lst);
23
24
// Insert at end - with Insert
Cached Result