Link to home
Start Free TrialLog in
Avatar of sitg
sitgFlag for Iceland

asked on

I have a problem I want to convert vb code to c# code

public object URLDecode(string What)
    {
        object functionReturnValue = null;
        int Pos;
        int pPos;
        What = What.ToString().Replace("+", " ");
        StringReader Stream = new StringReader(What);
        ErrorEventArgs Err;
        if (Convert.ToInt64(Err) == 0) {
            Pos = What.ToString().IndexOf("%",1);
            pPos = 1;
            while (Pos > 0) {
               pPos = Pos + 3;
               Pos = What.ToString().IndexOf("%", pPos);
            }
            Stream.WriteText(Strings.Mid(What, pPos));
            Stream.Position = 0;
            functionReturnValue = Stream.ReadToEnd();//.ReadText;
            Stream.Close();
        }
        else {
            Pos = What.ToString().IndexOf("%", 1);
            while (Pos > 0) {
               What = Strings.Left(What, Pos - 1) + Strings.Chr((long)"&H" + Strings.Mid(What, Pos + 1, 2)) + Strings.Mid(What, Pos + 3);
                Pos = Pos + 1;
                Pos = What.ToString().IndexOf("%", Pos);
            }
            functionReturnValue = What;
        }
        Stream = null;
        return functionReturnValue;
    }
     
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sitg

ASKER

thanks