zoukankan      html  css  js  c++  java
  • C# 字符串Trim进阶

    private void button1_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);                        
            }

    原文:https://www.cnblogs.com/Scholars/p/9162598.html

  • 相关阅读:
    ORB Test Hanson
    ajax异步传输中的乱码问题
    调用淘宝API遇到的问题
    doc命令查看电脑配置大全
    从关联数组中取得键名
    php图片上传
    doc命令查看电脑配置
    一个空间配置多个虚拟主机
    淘客网站中系统信息获取
    opendir(path,context)
  • 原文地址:https://www.cnblogs.com/zhang1f/p/11104960.html
Copyright © 2011-2022 走看看