java indexofany_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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值