-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Description
public int LastIndexOf(string value)
{
int idx = -1;
int last_find = -1;
while (true)
{
idx = internal_index_of(this._value, value, idx + value.Length);
last_find = idx;
if (idx == -1 || idx + value.Length >= this._value.Length)
break;
}
return last_find;
}
当internal_index_of() 返回-1时, last_find = idx;会覆盖上次的值,导致最终返回-1,
应该调整至if判断之后:
public int LastIndexOf(string value)
{
int idx = -1;
int last_find = -1;
while (true)
{
idx = internal_index_of(this._value, value, idx + value.Length);
if (idx == -1 || idx + value.Length >= this._value.Length)
break;
last_find = idx;
}
return last_find;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels