Wednesday, September 24, 2008

WordBreaker

public static string WordBreaker(string strWord, int breakingLength)
{
int len = strWord.Length;
if (len < breakingLength)
{
return strWord;
}

string output = string.Empty;
for (int count = 0; count < len; count += breakingLength)
{
// if(len/charCount+50)
int rem = len / (count + breakingLength);
if (rem != 0)
{
output += strWord.Substring(count, breakingLength) + "";
}
else
{
output += strWord.Substring(count, (len - count)) + " ";
}
}
return output;
}

No comments: