Click here to Skip to main content
15,878,814 members
Articles / Programming Languages / C#

C# Function to Calculate the Australian State from a Postcode

Rate me:
Please Sign up or sign in to vote.
2.00/5 (3 votes)
15 Sep 2021CPOL2 min read 7K   1  
Lots of forms require the Postcode AND the State, when it is a fixed relationship. Use this function and remove the need to collect the State as well.
Many web forms and other systems ask for the postcode as well as the State. In Australia, it is a simple relationship and does not currently require a complex lookup table, since each State or Territory has a fixed numeric range of postcodes. By executing an IF-ELSE-ELSE-ELSE... one can easily determine the State. It also deals with the fact that most web forms will have data entered as strings, and attempts to parse it, or defaults to one of the States.

Views

Daily Counts

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions