• c#中string类的方法


    以下对C#中string类的方法进行汇总:

    1.string (char[])      使用指定的字符串数组构建一个新的string对象

    2.int Compare(string a,string b,bool case)     比较字符串a,b,case为true时表示不区分大小写。当a>b返回正数,当a<b返回负数,a=b返回0

    3. bool EndsWith(string)         确定当前字符串是否以指定的字符串结尾

    4. bool StartsWith(string)         确定当前字符串是否以指定的字符串开头

    5.int IndexOf()               返回指定的字符或字符串在当前字符串中的位置

    6.int  LastIndexOf()        返回指定字符或字符串的最后一个匹配项位置

    7.string Insert(int,string)         在当前的字符串中插入一个指定的字符串

    8.string Replace(string,string)   字符串替换

    9.string Remove(int,int)               从指定位置开始删除指定个数的字符

    10. ToUpper()    ToLower()           字符串大小写转换

    11.string  SubString(int,int)          返回从指定位置开始指定个数的字符串

    下面举个例子对个别方法进行说明:

    string  str1=“Hello";

    string srr2="World";

    string Upper,str3;

    Upper=str1.Upper();     ///将str1转换为大写

    str3=str1.Insert(str1.Length,str2);    /// str3的内容为HelloWorld

  • 相关阅读:
    WebQQ2.0 PHP
    HTML文档类型 PHP
    字符●圆角 PHP
    IIS日志分析器 PHP
    JS 像素数字 PHP
    3DTagCloud3D标签云 PHP
    QQ截屏工具提取 PHP
    .NET嵌入DLL ILMerge工具应用 PHP
    JS CSS 压缩工具(GUI界面) PHP
    Javascript 函数初探
  • 原文地址:https://www.cnblogs.com/jiang2538406936/p/5162671.html
Copyright © 2020-2023  润新知