I stumbled upon this cool property of the System.Uri class today; the .NET Framework's Uri class knows that DNS names are case-insensitive. If you pass a string to a Uri constructor with mixed or upper case letters, the constructor will make the DNS/host part of the string lower-case.
So,
Uri uri = new Uri("http://WWW.YAHoo.com/FoO");
Console.WriteLine(Uri.Host);
will print: "www.yahoo.com"
Console.WriteLine(uri.AbsolutePath);
will print: "FoO"
No comments:
Post a Comment