Well I wrote out this function for an HTTP Wrapper im making:
Im fairly new to C# would someone mind pointing out whats wrong with this coding? I get an error with every one of the split actions >_< which saysCode:public string ExtractCookies(string strHeader) { string[] SplitStr; string[] Temp; string TempVal; string Key; string Value; int i; int TempHandler; string strCookies; SplitStr = strHeader.Split("\r\n"); for (i = 0; SplitStr.Length != 0; i++) { if (SplitStr[i].Contains("Set-Cookie")) { Temp = SplitStr[i].Split("Set-Cookie: "); Temp = Temp[1].Split("="); Key = Temp[0]; Temp = Temp[1].Split(";"); Value = Temp[0]; if (colCookies.Contains(Key)) { TempHandler = Convert.ToInt16(Key); TempVal = colCookies.GetByIndex(TempHandler); if (TempVal != Value) { colCookies.Remove(Key); colCookies.Add(Key, Key + "=" + Value + ";"); } } else { colCookies.Add(Key, Key + "=" + Value + ";"); } } } strCookies = ""; int j; for (j = 1; colCookies.Count != 0; j++) { strCookies = strCookies + colCookies.GetByIndex(j); } return strCookies; }and I get this error for the split actions aswellArgument '1': cannot convert from 'string' to 'char[]'and I get an error in this part:"The best overloaded method match for 'string.Split(params char[])' has some invalid arguments"
which says:Code:TempHandler = Convert.ToInt16(Key); TempVal = colCookies.GetByIndex(TempHandler);Does anyone know what Im doing wrong with the syntax?Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)
PS: Im using Microsoft Visual C# 2005 Express Edition




Reply With Quote