Helper for strings
This commit is contained in:
parent
6b092f8a41
commit
cb2b79be86
29
util/StringEx.cs
Normal file
29
util/StringEx.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static class StringEx
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public static int LastIndexOfWithMax( this string str, char c, int maxChars )
|
||||||
|
{
|
||||||
|
var strEnd = str.Length - 1;
|
||||||
|
|
||||||
|
if( strEnd < 2 )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for( int i = strEnd; i >= 0; i-- )
|
||||||
|
{
|
||||||
|
if( str[i] == c )
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user