determine if zip is alphanum - C#

Posted on 2012-08-22
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:knowlton
    LVL 5

    Accepted Solution

    LVL 5

    Author Comment

      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

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video discusses moving either the default database or any database to a new volume.

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now