Hey ho
No off-topic forum so I thought i'd shove it here instead
This is probably the most pointless algorithm I have ever written (C#)
Bet none of you can beat that :
No off-topic forum so I thought i'd shove it here instead
This is probably the most pointless algorithm I have ever written (C#)
Code:
static bool PostCodeCheck(string strPostCode)
{
/* This sub validates a UK Post Code
* Parameters: string postCode
* Returns: true if postcode is valid
* Copyright ?2004 Matthew Larsen - mat.larsen@gmail.com
*/
bool[] x = {true, true, false, false, false, true, true};
bool validateFail = false;
char[] postCode = strPostCode.ToCharArray();
if (postCode.Length > 7)
{ validateFail = false; }
else
{
int z = 0;
foreach (char y in postCode)
{
if ((y >= '0' && y <= '9') == x[z])
{ validateFail = false; break; }
else
{ validateFail = true; }
z = ++z;
}
}
return validateFail;
}
Bet none of you can beat that :