zoukankan      html  css  js  c++  java
  • C#学习(8)

    字符串学习:
                l.length 字符串长度,字符串个数
                 Console.WriteLine(s.Length );
                 Console.WriteLine(s.TrimStart()); //去掉前面的空格
                 s.TrimEnd();//去掉后边的空格
                 Console.WriteLine(s.ToLower ());//转换成小写
                 Console.WriteLine(s.ToUpper());//转换成大写
                 bool isbaohan = s.Contains("if");//判断字符串中是否包含某字符段
                 Console.WriteLine(isbaohan);
                 //字符串有长度,有索引  索引从0开始到length-1结束
                 int index = s.IndexOf("if",4);
                 Console.WriteLine(index);
                 int lastid = s.LastIndexOf("as");
                 Console.WriteLine(lastid );
                 string jqs = s.Substring(4,3);//(截取的索引位置,截取个数)
                 Console.WriteLine(jqs); 
                

    namespace ConsoleApplication6
    {
        class Program
        {
            static void Main(string[] args)
            {
                //身份证号截取生日
                Console.Write("请输入身份证号:");
                  string s = Console.ReadLine();
                  string a = s.Substring(6, 8);
                   Console.Write("你的生日是" + a);
           
              
                //从目标字符串截取第二个匹配的字符段
                    string x = "fewafdfreghythdbgafdregfsdafd";
                    int indes = x.IndexOf("afd");//找出第一个afd在第多少位
                    Console.WriteLine("第一个afd在第"+indes+"位   ");//第一个afd的位数
                    int index = x.IndexOf("afd",indes+1);//从第一个afd的f开始往后找第二个afd
                    Console.Write("第二个afd在第"+index+"位   ");//打印第二个afd的位数
                    string d = x.Substring(index,3);//截取第二个afd
                    Console.Write(d);
                  
                    Console.ReadLine();
            }
        }
    }

  • 相关阅读:
    启用了不安全的HTTP方法
    Ubuntu 16.04出现:Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh > /dev/null; fi'
    python发邮件
    糗事百科爬虫
    链接爬虫
    简单图片爬虫
    常见的非贪婪匹配
    [Selenium] WebDriver 操作 HTML5 中的 drag/drop
    [Selenium] 操作 HTML5 中的 Canvas 绘制图形
    [Selenium] WebDriver 操作 HTML5 中的 video
  • 原文地址:https://www.cnblogs.com/jakeasd/p/5344465.html
Copyright © 2011-2022 走看看