Retrieves country information by a country code.
The CountryInfo structure.
Method GetInfoByCountryCode is useful when you know the country code and want to get more information about a country with that code.
It is possible to specify either two or three letters code as an argument. Also the method is case-insensitive, i.e. you may specify code in upper case, lower case or even in mixed case. For example passing any of these arguments "US", "USA", "us", "uSa" will return CountryInfo for United States.
When country information for the specified code is absent and ThrowIfNotFound property is set to false method will return CountryInfo structure without significant information. If ThrowIfNotFound is set to true, the exception of type CountryInfoNotFoundException will be thrown.
| Exception Type | Condition |
|---|---|
| ArgumentNullException | Thrown when specified argument is a null reference (Nothing in Visual Basic). |
| ArgumentException | Thrown when specified argument contains less than two or more than three letters. |
| CountryInfoNotFoundException | Thrown when property ThrowIfNotFound is set to true and there is no country information with a specified code. |
See example for ThrowIfNotFound property.
IPInfo Class | ForAspNet.IPInfo Namespace