日期:2014-05-17 浏览次数:20985 次
public static class ExtendHelper
{
/// <summary>
/// Find some indexes of subString in a long string
/// </summary>
/// <param name="_input"></paramc
/// <param name="_lookfor"></param>
/// <param name="start"></param>
/// <returns></returns>
public static int[] FindIndexes(this String _input, String _lookfor, int start = 0)
{
List<int> result = new List<int>();
int Start = start < 0 ? 0 : start;
int current = _input.IndexOf(_lookfor, Start);
while (!current.Equals(-1))
{
result.Add(current);
current = _input.IndexOf(_lookfor, current + 1);
}
return result.ToArray();
}
//public static int[] FindIndexes(this String _input, char _lookfor, int start = 0)
//{
// List<int> result = new List<int>();
// int Start = start < 0 ? 0 : start;
// int current = _input.IndexOf(_lookfor, Start);