zoukankan      html  css  js  c++  java
  • C# 大小写转换,方便index of

    ToUpper:小写转大写
    ToLower:大写转小写

    例:

    string str=120cm*150g/m2;从中取出120和150,但是又要规避大小写问题,这时候就需要将str转换为大写,然后index of的时候使用大写进行查找

     string std ="120cm*150g/cm2".ToUpper();//全部转换为大写,方便下面查找
                    int sort1 = std.IndexOf("CM");
                    int sort2 = std.IndexOf("*");
                    int sort3 = std.IndexOf("G/M");
                    string width = string.Empty;
                    string weight = string.Empty;
                    if (sort1>0)
                    {
                        width = std.Substring(0, sort1);
                    }
                    if (sort2<sort3)
                    {
                        weight = std.Substring(sort2 + 1, sort3 - sort2-1);
                    }
    

      

  • 相关阅读:
    boostrapvalidator
    bootstrap 整理
    emil 的使用
    sass笔记
    sql 语句的优化
    多线程笔记
    mysql笔记
    react
    优雅的创建map/list集合
    spring中路径的注入
  • 原文地址:https://www.cnblogs.com/luoxueningchen/p/4953536.html
Copyright © 2011-2022 走看看