-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexing.cs
More file actions
21 lines (20 loc) · 936 Bytes
/
Indexing.cs
File metadata and controls
21 lines (20 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
namespace TheElm.Literals {
public static class Indexing {
/// <summary>
/// Find the IndexOf a <see cref="char"/> within the provided <see cref="string"/>.
/// If the <see cref="char"/> is not present, return the length of the <see cref="string"/>
/// </summary>
public static int IndexOfOrLen( this string input, char ch ) {
int index = input.IndexOf(ch);
return index is -1 ? input.Length : index;
}
/// <summary>
/// Find the IndexOf a <see cref="char"/> within the provided <see cref="string"/>.
/// If the <see cref="char"/> is not present, return the length of the <see cref="string"/>
/// </summary>
public static int IndexOfOrLen( this string input, char ch, int startPos ) {
int index = input.IndexOf(ch, startPos);
return index is -1 ? input.Length : index;
}
}
}