LumiSoft.Net.TextUtils.QuotedIndexOf C# (CSharp) Метод

QuotedIndexOf() публичный статический Метод

Gets first index of specified char. The specified char in quoted string is skipped. Returns -1 if specified char doesn't exist.
public static QuotedIndexOf ( string text, char indexChar ) : int
text string Text in what to check.
indexChar char Char what index to get.
Результат int
        public static int QuotedIndexOf(string text,char indexChar)
        {
            int  retVal         = -1;
            bool inQuotedString = false; // Holds flag if position is quoted string or not
            for(int i=0;i<text.Length;i++){
                char c = text[i];

                if(c == '\"'){
                    // Start/end quoted string area
                    inQuotedString = !inQuotedString;
                }

                // Current char is what index we want and it isn't in quoted string, return it's index
                if(!inQuotedString && c == indexChar){
                    return i;
                }
            }

            return retVal;
        }