M_Cyjb_StringView_IndexOf_7 - CYJB/Cyjb GitHub Wiki

StringView.IndexOf 方法 (ReadOnlySpan(Char), Int32, Int32, StringComparison)

返回当前字符串视图中指定字符串首次出现的索引。

Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public int IndexOf(
	ReadOnlySpan<char> value,
	int startIndex,
	int count,
	StringComparison comparisonType
)

参数

 

value
Type: System.ReadOnlySpan(Char)
要检查的字符串。
startIndex
Type: System.Int32
搜索起始位置。
count
Type: System.Int32
要搜索的字符个数。
comparisonType
Type: System.StringComparison
比较中要使用的规则。

返回值

Type: Int32
value 首次出现的索引,如果不存在则返回 -1

Exceptions

 

异常 条件
ArgumentOutOfRangeException startIndexcount 小于零。
ArgumentOutOfRangeException startIndex + count 表示的位置不在当前字符串视图内。

参见

Reference

StringView 结构
IndexOf 重载
Cyjb 命名空间

⚠️ **GitHub.com Fallback** ⚠️