zoukankan      html  css  js  c++  java
  • 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);                       
            }

  • 相关阅读:
    PHP unicode与普通字符串的相互转化
    PHP 日期之间所有日期
    PHP Excel导入日期单元格处理
    JS base64文件转化blob文件
    Mvc 刷新PartialView
    WebGL绘制变幻光斑
    WebGL笔记(四):初步封装
    WebGL笔记(目录)
    [JavaScript/canvas] 创建基于坐标访问的图形数据对象
    WebGL笔记(五):封装顶点和颜色等数组数据(二)
  • 原文地址:https://www.cnblogs.com/wwwzzg168/p/3570668.html
Copyright © 2011-2022 走看看