This is probably a fast implementation:
public static bool HasConsecutiveSpaces(string text)
{
bool inSpace = false;
foreach (char ch in text)
{
if (ch == ' ')
{
if (inSpace)
{
return true;
}
inSpace = true;
}
else
{
inSpace = false;
}
}
return false;
}
But if you don't really need to worry about speed, just use the regexp solution given in a previous answer.