static string stateFromPostcode(string postcodeString)
{
string returnState = "NSW";
int postcode = 0;
// Get a numeric postcode from a string entered; if the TryParse fails, then
// we will default to "NSW" anyway.
bool result = Int32.TryParse(postcodeString, out postcode);
if (result == true)
{
// These limits and assumptions are from [url]https://postcodes-australia.com[/url].
// By making the postcode numeric, and then ordering the checking that
// is done into numeric order, we can simplify the if-else-else to a simple
// "if less than number" in the majority of States and Territories.
if ((postcode > 799) && (postcode < 1000)) returnState = "NT";
else if (postcode < 2000) returnState = "NSW";
else if (((postcode > 2599) && (postcode < 2619)) ||
((postcode > 2899) && (postcode < 3000))) returnState = "ACT";
else if (postcode < 3000) returnState = "NSW";
else if (postcode < 4000) returnState = "VIC";
else if (postcode < 5000) returnState = "QLD";
else if (postcode < 6000) returnState = "SA";
else if (postcode < 7000) returnState = "WA";
else if (postcode < 8000) returnState = "TAS";
else returnState = "NSW";
} else returnState = "NSW";
return returnState;
}