Description:
Gets the second level domain from the given URI
Example:
Uri uri = new Uri("http://blog.jan-welker.de/2008/07/28/DieCommunityTermineImmerImBlick.aspx"); string secondLevelDomain = GetSecondLevelDomain(uri);
The result is: "jan-welker.de"
|
|
| C# |
1
2
3
4
5
6
7
8
9
10
11
|
/// <summary>
/// Gets the second level domain.
/// </summary>
/// <param name="uri">The URI.</param>
/// <returns></returns>
static string GetSecondLevelDomain(Uri uri)
{
string[] domains = uri.Host.Split(new char[] { '.' });
return (domains[domains.Length - 2] + "." + domains[domains.Length - 1]);
}
|
|
|
This Snippets could be interesting for you:
|
|
|
|
|
|
|
|
Comments:
(Please log in to wrtite an comment.)
|
|