private List <AddressInformation> GetRecords(IReadOnlyList <DnsResourceRecord> answers, ushort port, AddressFamily family) { var records = new List <AddressInformation>(); if (family == AddressFamily.InterNetwork) { records.AddRange(answers.ARecords() .Select(answer => new AddressInformation { IpAddress = answer.Address.ToString(), TimeToLive = answer.TimeToLive, CouldPing = PingHost(answer.Address.ToString(), port, family) })); } else if (family == AddressFamily.InterNetworkV6) { records.AddRange(answers.AaaaRecords() .Select(answer => new AddressInformation { IpAddress = answer.Address.ToString(), TimeToLive = answer.TimeToLive, CouldPing = PingHost(answer.Address.ToString(), port, family) })); } return(records); }