Use a try catch block.
var serversToTry = new []{"Server1", "Server2"};
foreach (var server in serversToTry)
{
try{
//connect to server
return; //if you made it this far, connection succedded.
}
catch (Exception e)
{
//log e if you want
}
}