Gets or sets value indicating whether to throw an exception when country information cannot be found.
true if exception must to be thrown when information is absent; otherwise false. The default is false.
The following example demonstrates using of ThrowIfNotFound property.
public void CheckCountryNames()
{
// assume what license is already initialized
// initializing a new instance of IPInfo
IPInfo ipi = new IPInfo();
CountryInfo ci = ipi.GetInfoByCountryCode("US");
string countryName = ci.CountryName; // countryName equals to "United States"
ci = ipi.GetInfoByCountryCode("XXX"); // not existed code is used; information is absent
countryName = ci.CountryName; // countryName equals to "N/A"
ipi.ThrowIfNotFound = true;
ci = ipi.GetInfoByCountryCode("XXX"); // exception of type CountryInfoNotFoundException is thrown !
}
IPInfo Class | ForAspNet.IPInfo Namespace