1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HOSTからIPaddressを取得する<C#>

Last updated at Posted at 2015-05-14

C#言語でHOSTからIPaddressを取得するコードを書いてみましょう。
using等は省略します。

~~~~~~~省略~~~~~~~
Console.Write("ホスト :: ");
var host = Console.ReadLine();

IPHostEntry ih = Dns.GethostEntry(host);

foreach(IPAddress ip in ih.AddressList)
{
Console.WriteLine(ip);
}

~~~~~~~省略~~~~~~~

こんな感じですね。
これでHostからIPaddressを取得できます。

1
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?