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

  • 相关阅读:
    JDBC_增删改
    JSP内置对象作用域
    497. Random Point in Non-overlapping Rectangles
    921. Minimum Add to Make Parentheses Valid
    946. Validate Stack Sequences
    824. Goat Latin
    Acwing 165 小猫爬山 (dfs)
    Codeforces #656 Problem D
    Codeforces #656 Problem C
    对象属性拷贝工具类大全
  • 原文地址:https://www.cnblogs.com/zhang1f/p/11104960.html
Copyright © 2011-2022 走看看