mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-06 07:29:06 +00:00
28 lines
526 B
C#
28 lines
526 B
C#
|
namespace MudBlazor;
|
|||
|
|
|||
|
internal static class StringLineEx
|
|||
|
{
|
|||
|
public static int IndexOf(this StringLine @this, string value, int startIndex = 0)
|
|||
|
{
|
|||
|
const int notFoundIndex = -1;
|
|||
|
|
|||
|
if (@this.Slice.Length < value.Length)
|
|||
|
return notFoundIndex;
|
|||
|
|
|||
|
for (var i = startIndex; i <= @this.Slice.Length - value.Length; i++)
|
|||
|
{
|
|||
|
var j = 0;
|
|||
|
for (; j < value.Length; j++)
|
|||
|
{
|
|||
|
if (@this.Slice[@this.Position + i + j] != value[j])
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
if (j == value.Length)
|
|||
|
return i;
|
|||
|
}
|
|||
|
|
|||
|
return notFoundIndex;
|
|||
|
}
|
|||
|
}
|