[Webinar] Learn how to a build a cloud-first strategyRegister Now


determine if zip is alphanum - C#

Posted on 2012-08-22
Medium Priority
Last Modified: 2012-08-22
private bool ZipIsAnAlphaNum(string zip)


Open in new window


Contains at least one alpha [a thru z]
Contains at least one integer [0 thru 9]

500 points for first to provide working code for the method above in C#.
Question by:Tom Knowlton
  • 2

Accepted Solution

Tom Knowlton earned 0 total points
ID: 38320797

Author Comment

by:Tom Knowlton
ID: 38320809
  public static bool IsValidAlphaNumeric(string inputStr)
            //make sure the user provided us with data to check
            //if not then return false
            if (string.IsNullOrEmpty(inputStr))
                return false;

            //now we need to loop through the string, examining each character
            for (int i = 0; i < inputStr.Length; i++)
                //if this character isn't a letter and it isn't a number then return false
                //because it means this isn't a valid alpha numeric string
                if (!(char.IsLetter(inputStr[i])) && (!(char.IsNumber(inputStr[i]))))
                    return false;

            //we made it this far so return true
            return true;

Open in new window


Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Integration Management Part 2
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question