enter image description here如何将元素添加到ArrayList C#中。我需要在键盘搜索项之前和之后添加一个元素。
case 5: string caut = Console.ReadLine(); Angajat t = listaAngaj.Find(x => x.Nume == caut);
int k = listaAngaj.IndexOf(t); listaAngaj.Insert(k + 1, new Angajat()); Console.WriteLine(k);
break;
case 6:
string caut1 = Console.ReadLine(); Angajat t1 = listaAngaj.Find(x => x.Nume == caut1);
int k1 = listaAngaj.IndexOf(t1); listaAngaj.Insert(k1, new Angajat()); Console.WriteLine(k1);
break;
这就是我在List中所做的事情