StartIndex cannot be less than zero.

Jun 4 2012 1:36 PM
Chief Coders,

A listbox with coded items a,b,c,d executes well with these variables but when working with values like CSC456, CSC555, CSC885, or any thing of such it outputs this->error

 
"StartIndex cannot be less than zero"


"System.ArgumentOutOfRangeException was unhandled
  Message=StartIndex cannot be less than zero.
Parameter name: startIndex
  Source=mscorlib
  ParamName=startIndex
  StackTrace:
       at Syst"


here is the code:

private string GetRemaining(string strChild, string strParent)
        {
            for (int i = 0; i < strChild.Length; i++)
            {
                int nIndex = strParent.IndexOf(strChild[i]);
                strParent = strParent.Remove(nIndex, 1);
            }
            return strParent;
        }

it points to this line:
strParent = strParent.Remove(nIndex, 1);
     

Please any help would be higly appreciated.

Attachment: apriori.zip

Answers (11)