Here's my C# version
<code>
private string GetWrappedText(string Text, int LineLength)
{
Text = Text.Replace("\r\n", "");
int len = Text.Length;
int startPos = 0;
StringBuilder sb = new StringBuilder();
while (((len - startPos) / LineLength) >= 1)
{
int endpoint = Text.Substring(startPos, LineLength).LastIndexOfAny(new char[] { ',', ' ', ':' });
sb.AppendLine(Text.Substring(startPos, endpoint));
startPos += endpoint + 1;
}
sb.Append(Text.Substring(startPos));
return sb.ToString();
}
</code>