开发者

remove dot at end of text

开发者 https://www.devze.com 2023-01-06 10:47 出处:网络
i have to remove the dot at the end of text howt to i do usign c#, dot.net example=abc. 开发者_开发问答i want this=abcTry this:

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


Try this:

string a = "abc.";
string b = a.TrimEnd('.'); 


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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消