c# list to string replace last comma with and

59

c# list to string replace last comma with and -

        var test = "Service Control Manager repeated 5 times, Microsoft-Windows-DistributedCOM repeated 2 times, Control Manager repeated 6 times.";
        var lastComma = test.LastIndexOf(',');
        if (lastComma != -1) test = test.Remove(lastComma, 1).Insert(lastComma, " and");

Comments

Submit
0 Comments