Search⌘ K
AI Features

Working with Network Resources

Explore how to work with network resources in C# using .NET types such as Uri, DNS, and IPAddress. Learn to extract parts of a URL, resolve IP addresses, and ping servers to verify connectivity. This lesson helps you understand practical methods for network programming in console applications.

Sometimes, we will need to work with network resources. The most common types in .NET for working with network resources are shown in the following table:

Namespace

Example Type(s)

Description

System.Net

Dns, Uri, Cookie, WebClient, IPAddress

These are for working with DNS servers, URIs, IP addresses, and so on.

System.Net

FtpStatusCode, FtpWebRequest, FtpWebResponse

These are for working with FTP servers.

System.Net

HttpStatusCode, HttpWebRequest, HttpWebResponse

These are for working with HTTP servers; that is, websites and services. Types from System.Net.Http are easier to use.

System.Net.Http

HttpClient, HttpMethod, HttpRequestMessage, HttpResponseMessage

These are for working with HTTP servers; that is, websites and services.

System.Net.Mail

Attachment, MailAddress, MailMessage, SmtpClient

These are for working with SMTP servers; that is, sending email messages.

System.Net.NetworkInformation

IPStatus, NetworkChange, Ping, TcpStatistics

These are for working with low-level network protocols.

Working with URIs, DNS, and IP addresses

Let’s explore some common types for working with network resources:

Step 1: Use your preferred code editor to add a new Console App or console project named ...