diff options
author | Stephen Toub <stoub@microsoft.com> | 2017-08-21 22:04:17 +0300 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2017-08-26 05:18:44 +0300 |
commit | 9a1ac0ef3f4871934b0eb202f725ae773c9f39ca (patch) | |
tree | e0a3d96931e600f89812bd8d19c690571fb3a65d /src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs | |
parent | eb981a73b88c0f923973f326c61f351ed6edf445 (diff) |
Merge pull request dotnet/coreclr#13424 from stephentoub/versionspan
Add span-based Version methods
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs b/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs index 4ec531cc3..dc285a2c2 100644 --- a/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs +++ b/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs @@ -73,5 +73,21 @@ namespace System return source.Slice(startIndex, endIndex - startIndex + 1); } + + public static int IndexOf(this ReadOnlySpan<char> source, char value) => + IndexOf(source, value, 0); + + public static int IndexOf(this ReadOnlySpan<char> source, char value, int startIndex) + { + for (int i = startIndex; i < source.Length; i++) + { + if (source[i] == value) + { + return i; + } + } + + return -1; + } } } |