현재 입력 텍스트 상자에 프록시 검사기를 만들고 있습니다. C# 오류가 발생했습니다 : 인덱스가 프록시 (123.34.123.45:8080) 배열 범위를 벗어났습니다.인덱스가 배열 오류 범위를 벗어났습니다.
내 코드는 것입니다 ...
string occoultProxy = "123.34.123.45:8080";
WebProxy proxy = new WebProxy(occoultProxy.Split(':')[0], Convert.ToInt32(occoultProxy.Split(':')[1])); //Error at this line
// WebProxy(string Host, int Port)
내가 다른 코드를 시도했지만 여전히 오류 코드가 있었다 업데이트되었습니다. 도와주세요.
string[] address = occoultProxy.Split(new[] { ':' });
MessageBox.Show(address[0].ToString());
MessageBox.Show(address[1].ToString());
WebProxy proxyHTTP = new WebProxy(address[0], Convert.ToInt32(address[1]));
출력
123.34.345.23 <!-- Some Proxy here, seems good here -->
IndexOutOfRangeException was unhandled(Index was outside the bounds of the array.)
나를 위해 작동합니다. occoultProxy를 얻는 데 문제가 있습니까? – ne2dmar
'occoultProxy'의 값이 포트 번호가없는 IP라고 추측합니다. – Rik
샘플을 사용해 보았지만 문제없이 실행됩니다. 문장에 전달한 문자열에 항상 세미콜론이 포함되어 있습니까? 사용자가 주소를 입력하게하기 때문에 세미콜론의 문자열을 확인해야합니다. – FoxHound