How to replace last character of the string using c#?

No.

In C# strings are immutable and thus you can not change the string “in-place”. You must first remove a part of the string and then create a new string. In fact, this is also means your original code is wrong, since str.Remove(str.Length -1, 1); doesn’t change str at all, it returns a new string! This should do:

str = str.Remove(str.Length -1, 1) + ",";

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)