Monthly Archives: February 2016

Generate random data in an Access database in C#

This example shows how you can generate random data for students and their test scores in an Access database. I often build examples that manipulate databases. Those examples are more interesting if the database holds lots of data, but it’s … Continue reading

Posted in ADO.NET, algorithms, database | Tagged , , , , , , , , , , , , , , | Leave a comment

Display master-detail data in a DataGrid in C#

At design time, I added the example’s Contacts.mdb database to the project, set its “Build Action” property to Content, and set its “Copy to Output Directory” property to “Copy if newer.” That way the database is copied into the executable … Continue reading

Posted in ADO.NET, controls, database | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | 1 Comment

Draw a recursive overlapping snowflake fractal in C#

   The example Draw a recursive snowflake fractal in C# explains how to use an iterator and a generator to draw a snowflake fractal. This example uses the same technique with the initiator and generator shown in the second and … Continue reading

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

Draw a recursive von Koch snowflake fractal in C#

   This example shows how to draw a von Koch snowflake fractal. It uses the same techniques described in the post Draw a recursive snowflake fractal in C#. The DrawSnowflake and DrawSnowflakeEdge methods are exactly the same as before. The … Continue reading

Posted in algorithms, drawing, fractals, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment

Draw a recursive snowflake fractal in C#

   This program draws a recursive snowflake fractal by using an initiator and a generator to define the fractal’s shape. The initiator is a curve that represent the fractal’s basic shape. In this case, the initiator is the triangle shown … Continue reading

Posted in algorithms, drawing, fractals, graphics, mathematics | Tagged , , , , , , , , , , , , , , , , | 12 Comments

Make an Excel chart in C#

This example uses the following code to create an Excel chart in a new workbook. private void btnCreateChart_Click( object sender, EventArgs e) { // Get the Excel application object. Excel.Application excel_app = new Excel.ApplicationClass(); // Make Excel visible (optional). excel_app.Visible … Continue reading

Posted in Excel, interoperability, Office | Tagged , , , , , , , , , , | Leave a comment

Graph mosquito populations in C#

The example Simulate mosquito populations in C# simulates a mosquito population. This example draws a graph showing the population during each generation. When it calculates the populations for a new generation, it stores them in the following lists. // Data … Continue reading

Posted in algorithms, animation, drawing, graphics, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment

Simulate mosquito populations in C#

A team of researchers at the Imperial College London are trying a new approach to mosquito control. They’ve genetically modified male mosquitoes to produce offspring who are 95% male. After a few generations, the number of females in the population … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , , , | 1 Comment

Calculate a row of Pascal’s triangle in C#

Pascal’s triangle starts with a 1 at the top. To construct a new row for the triangle, you add a 1 below and to the left of the row above. After that, each entry in the new row is the … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | 1 Comment

Print a Celsius to Fahrenheit conversion chart in C#

A friend of mine cooks a lot using Japanese cookbooks. Because ovens in the United States only display temperature in degrees Fahrenheit (someone should make that a switch on the oven), she needs to convert temperatures from Celsius to Fahrenheit. … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , , , , , , , | Leave a comment