Category Archives: strings

Draw different styles of “illuminated” text in C#

My previous post Draw “illuminated” text in C# showed how to draw “illuminated” text. It drew each paragraph’s initial letter in a large font with a box around it. Real illuminated manuscripts typically make the initial letter much more elaborate. … Continue reading

Posted in fonts, graphics, strings | Tagged , , , , , , , , , | Leave a comment

Draw “illuminated” text in C#

This example lets you draw “illuminated text” where each paragraph begins with an oversized letter. In some illuminated manuscripts, the first letter of a paragraph is drawn in a larger font than the remaining text. This example does something similar. … Continue reading

Posted in fonts, graphics, strings | Tagged , , , , , , , , , | 2 Comments

Make a Shakespeare insult generator in C#

This example shows how to build a Shakespeare insult generator by selecting one word from each of three arrays and combining the results. The following code shows the arrays (with many values omitted to save space). // The insult pieces … Continue reading

Posted in arrays, miscellany, strings | Tagged , , , , , , , , , , , , , , | Leave a comment

Rearrange text and format it to initialize variables in C#

This example takes three columns of strings, rearranges them so the values in each column are together, and reformats the results to produce text that you can use to initialize variables. The Shakespeare Insult Kit contains a table holding three … Continue reading

Posted in strings, variables | Tagged , , , , , , , , , , , , , | Leave a comment

Draw ransom note text in a RichTextBox in C#

This example is similar to the post Draw ransom note text in C# but it writes text into a RichTextBox instead of on a PictureBox. This has the following advantages. The code is simpler The RichTextBox can arrange text more … Continue reading

Posted in graphics, strings | Tagged , , , , , , , , , , , , | Leave a comment

Draw ransom note text in C#

This example draws each of the characters in a string in a different random font to produce a ransom note text effect. The program starts by using the following code to create arrays holding font names and brushes from which … Continue reading

Posted in graphics, strings | Tagged , , , , , , , , , , , , | 1 Comment

Write a CSV file from an array in C#

The example Read a CSV file into an array in C# shows how to load a CSV file into a two-dimensional array of strings. This example does the opposite: it saves a two-dimensional array of strings into a CSV (comma-separated … Continue reading

Posted in database, files, strings | Tagged , , , , , , , , , , , , , , | Leave a comment

Use XML literals in C#

Visual Basic lets you include XML literals directly in your code as in the following example. Dim employees As XElement = <employees> <employee firstname=”Terry” lastname=”Pratchett”/> <employee firstname=”Glen” lastname=”Cook”/> <employee firstname=”Tom” lastname=”Holt”/> <employee> <firstname>Rod</firstname> <lastname>Stephens</lastname> </employee> </employees> Unfortunately, C# doesn’t allow … Continue reading

Posted in strings, XML | Tagged , , , , , , , | Leave a comment

Use StringFormat to align text in columns in C#

My previous post Use tabs and StringFormat to align text in C# showed how to use a StringFormat object to draw tab-delimited text in columns. Unfortunately, that method doesn’t give you control over how the values in each column are … Continue reading

Posted in fonts, graphics, strings | Tagged , , , , , , , , , , , , , | 2 Comments

Use tabs and StringFormat to align text in C#

This example shows how you can use a StringFormat object to align tab-delimited text when drawing it on a window. The Graphics class’s DrawString method draws a string on a window, PictureBox, Bitmap, or other drawing surface. The DrawString method … Continue reading

Posted in fonts, graphics, strings | Tagged , , , , , , , , , , , , , | 1 Comment