using System; using System.Net; class Program { static void Main() { WebClient client = new WebClient(); string response = client.DownloadString("http://example.com"); int index = response.IndexOf("example"); Console.WriteLine("The word 'example' was found at index {0}", index); } }
using System; using System.Net; class Program { static void Main() { WebClient client = new WebClient(); string response = client.DownloadString("http://example.com"); int index = response.IndexOf('<'); Console.WriteLine("The first angle bracket was found at index {0}", index); } }This code will do the same thing as the previous example, except it will search for the first angle bracket "<" instead of the word "example". The System.Net WebClient class is part of the standard .NET library.