Compare commits

..

No commits in common. "main" and "latest" have entirely different histories.
main ... latest

1 changed files with 19 additions and 24 deletions

View File

@ -10,24 +10,19 @@ namespace SharpDNSResolver
class DNSResolver class DNSResolver
{ {
static void Main(string[] args) static void Main(string[] args)
{
if (args.Count() == 0)
{
Console.WriteLine("You must provide at least one host!");
Console.WriteLine("Usage: <prog.exe> <host1> [<host2> host<n>]");
Environment.Exit(1);
}
int cpt = 0;
string hostname;
IPHostEntry hostEntry;
for (cpt = 0; cpt < args.Length; cpt++)
{ {
try try
{ {
hostname = args[cpt]; if(args.Count() == 0)
hostEntry = Dns.GetHostEntry(hostname); {
Console.WriteLine($"\nHost : {hostEntry.HostName}"); Console.WriteLine("You must provide an host!");
Environment.Exit(1);
}
string hostname = args[0];
IPHostEntry hostEntry = Dns.GetHostEntry(hostname);
Console.WriteLine($"Host : {hostEntry.HostName}");
Console.WriteLine("Ip address:"); Console.WriteLine("Ip address:");
foreach (IPAddress ipAddress in hostEntry.AddressList) foreach (IPAddress ipAddress in hostEntry.AddressList)
{ {
@ -40,5 +35,5 @@ namespace SharpDNSResolver
} }
} }
} }
}
} }