Does a string have only one word

image_pdfimage_print
   
 

//The MIT License (MIT)
//http://arolibraries.codeplex.com/license
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AroLibraries.ExtensionMethods.Strings
{
    public static class StringExt
    {
        public static bool Ext_IsValidOneWord(this string iString)
        {
            if (!String.IsNullOrEmpty(iString))
            {
                string word = iString.Trim().ToLower();
                if (!String.IsNullOrEmpty(word))
                {
                    foreach (char c in word)
                    {
                        if (char.IsLetter(c) == false)
                        {
                            return false;
                        }
                    }
                    return true;
                }
            }
            return false;
        }
    }
}

   
     


This entry was posted in Data Types. Bookmark the permalink.