• 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

  • 相关阅读:
    集合总结
    dagger2系列之Scope
    dagger2系列之依赖方式dependencies、包含方式(从属方式)SubComponent
    dagger2系列之生成类实例
    Dagger2系列之使用方法
    Handler系列之内存泄漏
    Handler系列之创建子线程Handler
    Handler系列之原理分析
    Handler系列之使用
    HTML标签
  • 原文地址:https://www.cnblogs.com/zhang1f/p/11104960.html
Copyright © 2020-2023  润新知