• C#去掉字符串头尾指定字符


     private void button2_Click(object sender, EventArgs e)
            {//去掉字符串头尾指定字符
                string MyInfo= "--中华人民共和国--";
                //显示 "中华人民共和国"
                MessageBox.Show(MyInfo.Trim(new char[1] { '-' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);           
                MyInfo = ",-中华人民共和国-,-";
                //显示 "中华人民共和国"
                MessageBox.Show(MyInfo.Trim(new char[2] { '-', ',' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                       
                MyInfo = "--中华人民共和国--";
                //显示 "中华人民共和国--"
                MessageBox.Show(MyInfo.TrimStart(new char[1] { '-' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                       
                MyInfo = ",-中华人民共和国-,-";
                //显示 "中华人民共和国-,-"
                MessageBox.Show(MyInfo.TrimStart(new char[2] { '-', ',' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                       
                MyInfo = "--中华人民共和国--";
                //显示 "--中华人民共和国"
                MessageBox.Show(MyInfo.TrimEnd(new char[1] { '-' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                       
                MyInfo = ",-中华人民共和国-,-";
                //显示 ",-中华人民共和国"
                MessageBox.Show(MyInfo.TrimEnd(new char[2] { '-', ',' }), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);                       
            }

  • 相关阅读:
    WebView.简单使用_ZC代码
    WebView.简单使用_资料
    APK.错误解决_Theme.AppCompat.Light相关
    USB调试.红米Note4X
    Android_连接数据库_资料收集
    APK签名_ZC
    APK签名_资料
    ubuntu系统中代替windows系统中onenote软件--basket note pads
    firefox浏览器设置新页面后激活
    oracle 写declare例子
  • 原文地址:https://www.cnblogs.com/wwwzzg168/p/3570668.html
Copyright © 2020-2023  润新知