zoukankan      html  css  js  c++  java
  • String对象的方法

    Function

    Description

    Example

    CompareTo()

    Compares one string to another

    ("Hello").CompareTo("Hello")

    Contains()

    Returns "True" if a specified comparison string is in a string or if the comparison string is empty

    ("Hello").Contains("ll")

    CopyTo()

    Copies part of a string to another string

    $a = ("Hello World").toCharArray()
    ("User!").CopyTo(0, $a, 6, 5)
    $a

    EndsWith()

    Tests whether the string ends with a specified string

    ("Hello").EndsWith("lo")

    Equals()

    Tests whether one string is identical to another string

    ("Hello").Equals($a)

    IndexOf()

    Returns the index of the first occurrence of a comparison string

    ("Hello").IndexOf("l")

    IndexOfAny()

    Returns the index of the first occurrence of any character in a comparison string

    ("Hello").IndexOfAny("loe")

    Insert()

    Inserts new string at a specified index in an existing string

    ("Hello World").Insert(6, "brave ")

    GetEnumerator()

    Retrieves a new object that can enumerate all characters of a string

    ("Hello").GetEnumerator()

    LastIndexOf()

    Finds the index of the last occurrence of a specified character

    ("Hello").LastIndexOf("l")

    LastIndexOfAny()

    Finds the index of the last occurrence of any character of a specified string

    ("Hello").LastIndexOfAny("loe")

    PadLeft()

    Pads a string to a specified length and adds blank characters to the left (right-aligned string)

    ("Hello").PadLeft(10)

    PadRight()

    Pads string to a specified length and adds blank characters to the right (left-aligned string)

    ("Hello").PadRight(10) + "World!"

    Remove()

    Removes any requested number of characters starting from a specified position

    ("Hello World").Remove(5,6)

    Replace()

    Replaces a character with another character

    ("Hello World").Replace("l", "x")

    Split()

    Converts a string with specified splitting points into an array

    ("Hello World").Split("l")

    StartsWith()

    Tests whether a string begins with a specified character

    ("Hello World").StartsWith("He")

    Substring()

    Extracts characters from a string

    ("Hello World").Substring(4, 3)

    ToCharArray()

    Converts a string into a character array

    ("Hello World").toCharArray()

    ToLower()

    Converts a string to lowercase

    ("Hello World").toLower()

    ToLowerInvariant()

    Converts a string to lowercase using casing rules of the invariant language

    ("Hello World").toLowerInvariant()

    ToUpper()

    Converts a string to uppercase

    ("Hello World").toUpper()

    ToUpperInvariant()

    Converts a string to uppercase using casing rules of the invariant language

    ("Hello World").ToUpperInvariant()

    Trim()

    Removes blank characters to the right and left

    (" Hello ").Trim() + "World"

    TrimEnd()

    Removes blank characters to the right

    (" Hello ").TrimEnd() + "World"

    TrimStart()

    Removes blank characters to the left

    (" Hello ").TrimStart() + "World"

    Chars()

    Provides a character at the specified position

    ("Hello").Chars(0)

  • 相关阅读:
    我的航拍直升机 控制基站软件的编写历程(2.2)——Qt Creator 版本控制系统
    windows下QT开发环境建立方法
    QT 4.5 windows版本 安装问题 及 Junction 使用
    各种平台下编译qt工程
    华为面试题
    strcpy,strncpy,strlcpy,memcpy
    QT/E 更换字体问题
    Linux设备驱动编程中断处理
    oracle数据库连接池的使用
    Windows下QT的安装
  • 原文地址:https://www.cnblogs.com/IvanChen/p/4493001.html
Copyright © 2011-2022 走看看