Home > Backend Development > C#.Net Tutorial > C# Remove specified characters at the end of a string

C# Remove specified characters at the end of a string

黄舟
Release: 2016-12-27 13:52:28
Original
2365 people have browsed it

#region 移除字符串末尾指定字符
      /// <summary> 
      /// 移除字符串末尾指定字符 
      /// </summary> 
      ///<param name="str">需要移除的字符串 
      ///<param name="value">指定字符 
      /// <returns>移除后的字符串</returns> 
      public static string RemoveLastChar(string str, string value)
      {
          int _finded = str.LastIndexOf(value);
          if (_finded != -1)
          {
              return str.Substring(0, _finded);
          }
          return str;
      }
      #endregion
Copy after login

The above is the content of C# to remove the specified characters at the end of the string. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template