zoukankan      html  css  js  c++  java
  • C# 移除字符串头尾指定字符

     1  private void button1_Click(object sender, EventArgs e)
     2         {//去掉字符串头尾指定字符
     3             string MyInfo= "--中华人民共和国--";
     4             //显示 "中华人民共和国"
     5             MessageBox.Show(MyInfo.Trim(new char[1] { '-' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);            
     6             MyInfo = ",-中华人民共和国-,-";
     7             //显示 "中华人民共和国"
     8             MessageBox.Show(MyInfo.Trim(new char[2] { '-', ',' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                        
     9             MyInfo = "--中华人民共和国--";
    10             //显示 "中华人民共和国--"
    11             MessageBox.Show(MyInfo.TrimStart(new char[1] { '-' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                        
    12             MyInfo = ",-中华人民共和国-,-";
    13             //显示 "中华人民共和国-,-"
    14             MessageBox.Show(MyInfo.TrimStart(new char[2] { '-', ',' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                        
    15             MyInfo = "--中华人民共和国--";
    16             //显示 "--中华人民共和国"
    17             MessageBox.Show(MyInfo.TrimEnd(new char[1] { '-' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                        
    18             MyInfo = ",-中华人民共和国-,-";
    19             //显示 ",-中华人民共和国"
    20             MessageBox.Show(MyInfo.TrimEnd(new char[2] { '-', ',' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                        
    21         }
  • 相关阅读:
    zoj_3710Friends
    javamail例子
    HttpURLConnection类的用法
    发送邮件协议
    栈的定义
    tomcat中添加jconsole服务
    HttpURLConnection类的用法
    javamail例子
    tomcat中添加jconsole服务
    栈的定义
  • 原文地址:https://www.cnblogs.com/Scholars/p/9162598.html
Copyright © 2011-2022 走看看