Dev2.Data.Operations.Dev2IndexFinder.FindIndex C# (CSharp) Method

FindIndex() public method

public FindIndex ( string stringToSearchIn, enIndexFinderOccurrence occurrence, string charsToSearchFor, enIndexFinderDirection direction, bool matchCase, int startIndex ) : IEnumerable
stringToSearchIn string
occurrence enIndexFinderOccurrence
charsToSearchFor string
direction enIndexFinderDirection
matchCase bool
startIndex int
return IEnumerable
        public IEnumerable<int> FindIndex(string stringToSearchIn, enIndexFinderOccurrence occurrence, string charsToSearchFor, enIndexFinderDirection direction, bool matchCase, int startIndex)
        {
            IEnumerable<int> result = new[] { -1 };


            if(!string.IsNullOrEmpty(stringToSearchIn) && !string.IsNullOrEmpty(charsToSearchFor))
            {
                #region Calculate the index according to what the user enterd

                var comparisonType = matchCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
                int firstIndex = stringToSearchIn.IndexOf(charsToSearchFor, startIndex, comparisonType);
                int lastIndex = stringToSearchIn.LastIndexOf(charsToSearchFor, stringToSearchIn.Length - 1, comparisonType);

                if(direction == enIndexFinderDirection.RightToLeft)
                {
                    result = RightToLeftIndexSearch(occurrence, firstIndex, lastIndex, stringToSearchIn, charsToSearchFor,
                                                    comparisonType);
                }
                else
                {
                    result = LeftToRightIndexSearch(occurrence, firstIndex, lastIndex, stringToSearchIn, charsToSearchFor,
                                                    comparisonType);
                }

                #endregion
            }
            return result;
        }

Same methods

Dev2IndexFinder::FindIndex ( string stringToSearchIn, string firstOccurrence, string charsToSearchFor, string direction, bool matchCase, string startIndex ) : IEnumerable