Minor modification to Greg + Tomino's excellent method above to capitalize the first word of each sentence. I also removed the trailing newline and removed some "+ 1"s that gave one too many. Very handy for testing word wrap capabilities of user interfaces! Thanks to Tomino & Greg.
private static string LoremIpsum(int minWords, int maxWords, int minSentences, int maxSentences, int numLines)
{
var words = new[]{"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer", "adipiscing", "elit", "sed", "diam", "nonummy", "nibh", "euismod", "tincidunt", "ut", "laoreet", "dolore", "magna", "aliquam", "erat"};
var rand = new Random();
int numSentences = rand.Next(maxSentences - minSentences)
+ minSentences;
int numWords = rand.Next(maxWords - minWords) + minWords;
var sb = new StringBuilder();
for (int p = 0; p < numLines; p++)
{
for (int s = 0; s < numSentences; s++)
{
for( int w = 0; w < numWords; w++ )
{
if( w > 0 ) { sb.Append( " " ); }
string word = words[ rand.Next( words.Length ) ];
if( w == 0 ) { word = word.Substring( 0, 1 ).Trim().ToUpper() + word.Substring( 1 ); }
sb.Append( word );
}
sb.Append(". ");
}
if ( p < numLines-1 ) sb.AppendLine();
}
return sb.ToString();
}