LastIndexOf
returns an integer, not a string. Replace
accepts string, string
as parameters, you pass it int, string
, so the exception The best overloaded method for 'string.Replace(string,string)' has some invalid arguements.
If you just want to delete everything, use this:
strLine = strLine.Replace(",", "");
Based on your code, you might want to replace the last instance, so try this if you want:
StringBuilder sb = new StringBuilder(strLine); sb[strLine.LastIndexOf(",")] = ""; strLine = sb.ToString();
source share