• C#函数(六)


    27、Remove()
    从指定位置开始删除指定数的字符
    字串对比一般都用: if(str1==str2){ } , 但还有别的方法:

    1、
    string str1; str2
    //语法: str1.EndsWith(str2); __检测字串str1是否以字串str2结尾,返回布尔值.如:
    if(str1.EndsWith(str2)){ Response.Write("字串str1是以"+str2+"结束的"); }

    2、
    //语法:str1.Equals(str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上.

    3、
    //语法 Equals(str1,str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上.

    IndexOf()
    查找字串中指定字符或字串首次出现的位置,返首索引值,如:
    str1.IndexOf("字"); //查找“字”在str1中的索引值(位置)
    str1.IndexOf("字串");//查找“字串”的第一个字符在str1中的索引值(位置)
    str1.IndexOf("字串",3,2);//从str1第4个字符起,查找2个字符,查找“字串”的第一个字符在str1中的索引值(位置)

    1.9 取中文日期显示——年月日时分
    string strY=currentTime.ToString("f"); //不显示秒

    1.10 取中文日期显示_年月
    string strYM=currentTime.ToString("y");

    1.11 取中文日期显示_月日
    string strMD=currentTime.ToString("m");

    1.12 取当前年月日,格式为:2003-9-23
    string strYMD=currentTime.ToString("d");

    1.13 取当前时分,格式为:14:24
    string strT=currentTime.ToString("t");
    更新一下, 上面不能编辑:

    c#.net函数和方法集(大家一起来加啊)


    1、DateTime 数字型
    System.DateTime currentTime=new System.DateTime();
    1.1 取当前年月日时分秒
    currentTime=System.DateTime.Now;
    1.2 取当前年
    int 年=currentTime.Year;
    1.3 取当前月
    int 月=currentTime.Month;
    1.4 取当前日
    int 日=currentTime.Day;
    1.5 取当前时
    int 时=currentTime.Hour;
    1.6 取当前分
    int 分=currentTime.Minute;
    1.7 取当前秒
    int 秒=currentTime.Second;
    1.8 取当前毫秒
    int 毫秒=currentTime.Millisecond;
    (变量可用中文)

  • 相关阅读:
    python 查询文件存放地址
    类数组对象:arguments
    前端开发工程师从入门到精通学习过程及资源总结(持续更新中)
    CSS3的圆角border-radius属性
    内联元素inline-block空隙问题
    js中typeof用法详细介绍
    正则表达式
    sublime text 3 快捷键大全以及配置编译环境
    c# 泛型类
    c# 中config.exe 引发的一些问题
  • 原文地址:https://www.cnblogs.com/atun/p/2053647.html
Copyright © 2020-2023  润新知