I see your comment now, so try this:
foreach (string proxy in proxies) // proxies is the list entered by user
{
// proxy is the proxy you must try for three times;
bool proxy_works = test_proxy(); // test function you must write
// if you need to find first working proxy and then stop
// use next statements, on the contrary remove them
// and you'll travel the whole list
if (proxy_works)
{
// do here what you need (save working proxy?!?)
break;
}
}
If your user enters proxies separated by comma (for example) you can build proxies as follows:
string[] proxies = strProxy.Split(",".ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
or if you want to read from file:
string[] proxies = File.ReadAllLines(file_path);
If every proxy is done as host_name:port
you can do
string vars = proxy.Split(':'.ToCharArray());
if (vars.Length == 2)
{
string MyProxyHostString = vars[0];
int MyProxyPort = int.Parse(vars[1]); // Better if you use int.TryParse method
}