Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove dot at end of text

Tags:

string

c#

.net

i have to remove the dot at the end of text howt to i do

usign c#, dot.net

example = abc.

i want this = abc

like image 456
azeem Avatar asked Jul 07 '10 01:07

azeem


People also ask

How do you remove a dot at the end of a word in Excel?

Go to variable view. click on Type. Change from numeric to string and the dots will disappear.

How do I remove a dot between names in Excel?

Edit > Replace, replace .


2 Answers

Try this:

string a = "abc.";
string b = a.TrimEnd('.'); 
like image 91
Matt Mitchell Avatar answered Oct 18 '22 12:10

Matt Mitchell


You can remove any dots at the end of a string using the TrimEnd method:

str = str.TrimEnd('.');

You can use the Substring method to remove only the last character:

str = str.Substring(0, str.Length - 1);

If the last character should only be removed if it's a period, you can check for that first:

if (str[str.Length - 1] == '.') {
  str = str.Substring(0, str.Length - 1);
}
like image 29
Guffa Avatar answered Oct 18 '22 10:10

Guffa