Monthly Archives: March 2016

Copy and paste scribble data in C#

The example Save and restore pictures drawn by the user in C# shows how to make a simple drawing program. The example Copy and paste objects to the clipboard in C# shows how to copy objects to the clipboard. This … Continue reading

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

Use XOR to swap two numbers in C#

Note that I don’t recommend this technique for swapping numbers. It’s mostly a clever trick that provides a lesson in the bitwise XOR operation. The code is much easier to understand if you just declare a temporary variable to make … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , | Leave a comment

Make a ComboBox display images with text in C#

The example Make a ComboBox display colors or images in C# shows how to make an owner-drawn ComboBox that displays either a series of color samples or a list of images. This example shows how to make a ComboBox that … Continue reading

Posted in controls, extension methods, graphics | Tagged , , , , , , , , , , , , | 6 Comments

Make a ComboBox display colors or images in C#

There are two kinds of owner-drawn ComboBox controls. In the first kind, every item has the same size. In the second kind of ComboBox, each item can have a different size. Same Sized Items To make all items have the … Continue reading

Posted in controls, extension methods, graphics | Tagged , , , , , , , , , , , , | 1 Comment

See if the mouse is over a curve in C#

The post Draw a smooth curve connecting points in C# uses the Graphics class’s DrawCurve method to draw a smooth curve that connects a collection of points. This example shows how you can tell when the mouse is over the … Continue reading

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

Add useful extensions to the BitArray class in C#

The example Use the BitArray class in C# explains how to use the BitArray class. This example adds some useful features to the BitArray class as extension methods. The following code shows the NumTrue and NumFalse extension methods, which respectively … Continue reading

Posted in classes, extension methods | Tagged , , , , , , , , | Leave a comment

Use the BitArray class in C#

The BitArray class stores an array of Boolean values packed into a bit array to save space. The size of the BitArray in bytes depends on the number of bits it contains and on the size of the word on … Continue reading

Posted in classes | Tagged , , , , , , | 1 Comment

Refine the complex number class in C#

This example shows how to refine the complex number class defined by the example Make a complex number class that works with real numbers in C#. That example explains how to build a Complex class that represents complex numbers. It … Continue reading

Posted in classes, mathematics, OOP, operators | Tagged , , , , , , , , , , , , , , , | 1 Comment

Make a complex number class that works with real numbers in C#

The example Make a complex number class with overloaded operators in C# builds a simple Complex class that includes overloaded +, -, *, and / operators that let you combine Complex objects. For example, a program can execute the following … Continue reading

Posted in classes, mathematics, OOP, operators | Tagged , , , , , , , , , , , , , , , | 1 Comment

Make a complex number class with equality in C#

The example Make a complex number class with overloaded operators in C# builds a simple Complex class that includes overloaded +, -, *, and / operators that let you combine Complex objects. For example, a program can execute the following … Continue reading

Posted in classes, mathematics, OOP, operators | Tagged , , , , , , , , , , , , , , , | 3 Comments