Given a URL as follows:
foo.bar.car.com.au
I need to extract foo.bar.
foo.bar
I came across the following code :
pr
I would recommend using Regular Expression. The following code snippet should extract what you are looking for...
string input = "foo.bar.car.com.au"; var match = Regex.Match(input, @"^\w*\.\w*\.\w*"); var output = match.Value;