checks if a string is null or empty or is made only of spaces

image_pdfimage_print

//CruiseControl is open source software and is developed and maintained by a group of dedicated volunteers.
//CruiseControl is distributed under a BSD-style license.
//http://cruisecontrol.sourceforge.net/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace ThoughtWorks.CruiseControl.Core.Util
{
///

/// Class with handy stirng routines
///

public class StringUtil
{

///

/// checks if a string is null or empty or is made only of spaces
///

/// ///
public static bool IsWhitespace(string input)
{
if (string.IsNullOrEmpty(input))
{
return true;
}
else
{
// Check each character to see if it is whitespace or not
var isWhiteSpace = true;
for (var loop = 0; loop < input.Length; loop++) { if (!char.IsWhiteSpace(input[loop])) { isWhiteSpace = false; break; } } return isWhiteSpace; } } } } [/csharp]

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