View Single Post
Old Nov 9th, 2005, 2:15 PM   #4
allenm
Newbie
 
Join Date: Nov 2005
Posts: 3
Rep Power: 0 allenm is on a distinguished road
Exclamation

string ConvertCodes( string binary )
{
 // what to return
 string retval = "";
 
 // what to restore the passed in value to just incase
 string tempCopy = binary;
 
 foreach( PairItem i in CodeList )
 {
    // if the CODE (i.e. "011") is a prefix of the passed in string
    if( binary.StartsWith( i.CODE ) )
    {
      // add the symbol (i.e. "i") to the return value string
      retval+=i.Symbol.ToString();
     
      // update the passed in string for further checking
      binary = binary.SubString( i.CODE.Length );
      
      // check the update string, if it equals "", there were no further matches
      if( ConvertCodes(binary) == "" )
      {
        // reset the return value
        retval = "";

        // restore the passed in string
        binary = tempCopy;
      }
    }
 }

 return retval
}

I ran through this code in debug mode for a simple string, and it found the correct return value, but it still returned "".
allenm is offline   Reply With Quote