C# How get domain from any string [duplicate]

Solution 1:

This should work.

new Uri("http://stackoverflow.com/questions").DnsSafeHost