代码改变世界

字符定位

2012-12-24 23:30  hongjiumu  阅读(259)  评论(0编辑  收藏  举报
private void SetPositionReference(string input)
        {
            _vdPostionReference.Clear();
            int currentIndex = 0;
            char currentChar;
            int iStartIndex = 0, iEndIndex = 0;
            string tempColumnName = string.Empty;
            int iColumnIndex = 0;
            while (currentIndex < input.Length)
            {
                currentChar = input[currentIndex++];
                while (_vsDelimiter.Contains<char>(currentChar))
                {
                    currentIndex++;
                    if (currentIndex >= input.Length) break;
                    currentChar = input[currentIndex];
                }
                iStartIndex = currentIndex;
                while (!_vsDelimiter.Contains<char>(currentChar))
                {
                    currentIndex++;
                    if (currentIndex == input.Length) break;
                    currentChar = input[currentIndex];
                }
                iEndIndex = currentIndex - 1;
                tempColumnName = input.Substring(iStartIndex, iEndIndex - iStartIndex + 1);

                _vdPostionReference.Add(iColumnIndex++, tempColumnName);

                currentIndex++;
            }
        }