zoukankan      html  css  js  c++  java
  • string类

    string s=" dsdsasadds";
    //1.Length属性 字符串的长度,也是字符的个数
    Console.WriteLine(s.Length);
    Console.WriteLine(s.TrimStart());//去除左边空格q
    Console.WriteLine(s.TrimEnd());//去除右边空格
    Console.WriteLine(s.ToUpper());//转换成大写
    Console.WriteLine(s.ToLower());//转换成小写

    bool isbaohan =s.Contains("asd");//判断字符串中是否包含某字符
    Console.WriteLine(isbaohan);

    //z字符串右长度,有索引 索引从0开始到Length-1结束
    int index =s.IndexOf("add",5);//从第五位开始找add
    int lastid =s.LastIndexOf("as");//找最后的一个as
    Console.WriteLine(lastid);

    string jqs=s.Substring(4);从第四位开始截取

    string jqs=s.Substring(4,9);从第四位开始截取,往回截取9位
    Console.WriteLine(jqs);

    例:

    输入身份证号,截取出生年月日

    Console.WriteLine("请输入你的身份证号");
    string s=Console.ReadLine();
    string jq1 = s.Substring(6, 4);
    string jq2 = s.Substring(10, 2);
    string jq3 = s.Substring(12, 2);
    Console.WriteLine("您的出生年月日是"+jq1+"年"+jq2+"月"+jq3+"日")

  • 相关阅读:
    adobe acrobat 无效批注对象
    分享下今天研究的流量上限DDos攻击分析和解决方式
    【二】【HTML列表、表格与框架】
    大话计算机中的流水作业
    texinfo
    texindex
    texi2dvi
    tex, virtex, initex
    testprns printername [printcapname]
    testparm
  • 原文地址:https://www.cnblogs.com/jskbk/p/5344471.html
Copyright © 2011-2022 走看看