Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove single character from a string?

Tags:

string

c#

How would you remove a single character from a string?

string = string.Remove(3);

but it removes the third char and everything else.

like image 262
Steve Avatar asked Jan 22 '12 19:01

Steve


1 Answers

According to the remove method signature:

public string Remove(
    int startIndex,
    int count
)

you need to provide a second parameter as the total number of characters to remove from startIndex:

string = string.Remove(3, 1);
like image 131
B Faley Avatar answered Sep 18 '22 08:09

B Faley