fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. List<string> list = (new string[] {
  10. "Shekhar1", "Shekhar2", "Shekhar3", "Shekhar4", "Shekhar5" }
  11. ).ToList();
  12.  
  13. string match = "Shekhar3";
  14. string replace = "Shekhar88";
  15. List<string> newList = list.Select(x => x == match ? replace : x).ToList();
  16. list = newList;
  17. foreach (string value in list) {
  18. Console.WriteLine("{0}", value);
  19. }
  20. }
  21. }
Success #stdin #stdout 0.03s 33792KB
stdin
Standard input is empty
stdout
Shekhar1
Shekhar2
Shekhar88
Shekhar4
Shekhar5