System.Delimiter.GetSubstring C# (CSharp) Méthode

GetSubstring() public static méthode

public static GetSubstring ( string s, int &i, DelimitType dt ) : DIndices
s string
i int
dt DelimitType
Résultat DIndices
        public static DIndices GetSubstring(string s, ref int i, DelimitType dt)
        {
            DIndices di = new DIndices();
            di.Type = DelimitType.None;
            if(i < 0) {
                di.Start = -1;
                return di;
            }

            // Find The First Character
            while(i < s.Length - 1) {
                if(IsOpener(s[i], dt)) {
                    di.Type = GetDType(s[i]);
                    i++;
                    break;
                }
                i++;
            }

            // Could Not Find The First Character
            if(di.Type == DelimitType.None)
                return di;

            // Find The Last Character
            di.Start = i;
            int open = 1;
            while(i < s.Length && open > 0) {
                if(IsOpener(s[i], di.Type)) {
                    open++;
                }
                else if(IsCloser(s[i], di.Type)) {
                    open--;
                    if(open == 0) {
                        di.End = i - 1;
                        return di;
                    }
                }
                i++;
            }

            // Could Not Find The Last Character
            di.Type = DelimitType.None;
            return di;
        }