System::String::IndexOf 方法

String::IndexOf(char_t, int, int) const method

子串中的字符向前查找。

int System::String::IndexOf(char_t c, int startIndex, int count) const
参数类型描述
cchar_t要查找的字符。
startIndexint开始查找的索引。
countint要遍历的字符数。

ReturnValue

自 startIndex 起的第一个字符位置索引,如果未找到则为 -1。

另见

String::IndexOf(char_t, int) const method

字符向前查找。

int System::String::IndexOf(char_t c, int startIndex=0) const
参数类型描述
cchar_t要查找的字符。
startIndexint开始查找的索引。

ReturnValue

自 startIndex 起的第一个字符位置索引,如果未找到则为 -1。

另见

String::IndexOf(const String&, int, int) const method

子串前向查找。

int System::String::IndexOf(const String &str, int startIndex, int count) const
参数类型描述
strconst String&要查找的子字符串。
startIndexint在源字符串中开始查找的位置。
countint要查找的字符数量。

ReturnValue

首次找到的子串索引,若未找到则返回 -1。对于空的查找字符串,总是返回 startIndex。

另见

String::IndexOf(const String&, int, System::StringComparison) const method

子串前向查找。

int System::String::IndexOf(const String &str, int startIndex, System::StringComparison comparison_type) const
参数类型描述
strconst String&要查找的子字符串。
startIndexint在源字符串中开始查找的位置。
comparison_typeSystem::StringComparisonComparison 模式。

ReturnValue

首次找到的子串索引,若未找到则返回 -1。对于空的查找字符串,总是返回 startIndex。

另见

String::IndexOf(const String&, int) const method

子串前向查找。

int System::String::IndexOf(const String &str, int startIndex=0) const
参数类型描述
strconst String&要查找的子字符串。
startIndexint在源字符串中开始查找的位置。

ReturnValue

首次找到的子串索引,若未找到则返回 -1。对于空的查找字符串,总是返回 startIndex。

另见

String::IndexOf(const String&, System::StringComparison) const method

子串前向查找。

int System::String::IndexOf(const String &str, System::StringComparison comparison_type) const
参数类型描述
strconst String&要查找的子字符串。
comparison_typeSystem::StringComparisonComparison 模式。

ReturnValue

首次找到的子串索引,若未找到则返回 -1。对于空的查找字符串,总是返回 0。

另见

String::IndexOf(const String&, int, int, System::StringComparison) const method

子串前向查找。

int System::String::IndexOf(const String &value, int startIndex, int count, System::StringComparison comparisonType) const
参数类型描述
const String&要查找的子字符串。
startIndexint在源字符串中开始查找的位置。
countint要查找的字符数量。
comparisonTypeSystem::StringComparisonComparison 模式。

ReturnValue

首次找到的子串索引,若未找到则返回 -1。对于空的查找字符串,总是返回 startIndex。

另见