Created
December 3, 2014 15:20
-
-
Save JamisonWhite/4f4540b2af9d8f657dd2 to your computer and use it in GitHub Desktop.
Get all subdomains of a domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Get all labels of the domain. Item 0 is always TLD. | |
/// </summary> | |
/// <param name="domain"></param> | |
/// <returns></returns> | |
public static IEnumerable<string> GetDomainSubdomains(string domain) | |
{ | |
var parts = domain.Split('.').ToArray(); | |
var labels = new List<String>(parts.Length + 1); | |
for (var i = 0; i < parts.Length; i++) | |
{ | |
labels.Add(String.Join(".", parts.Skip(i))); | |
} | |
return labels; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment