Monthly Archives: November 2013

Perform set operations such as union and intersection on enumerable lists in C#

This example creates two sets of Person objects. The Person class implements IEquatable. The code then uses the following code to display the lists and their intersection, union, difference, and exclusive or (xor). // Display the values. lstA.DataSource = list_a; … Continue reading

Posted in mathematics | Leave a comment

The most popular C# Helper posts over the last 12 months

Just for fun, here’s a list of the top posts over the last 12 months. This isn’t “fair” to the most recent posts because they haven’t been posted for as long. I still think it’s pretty interesting. I wouldn’t have … Continue reading

Posted in miscellany | Leave a comment

Determine whether two lists contain the same sequences of objects in different orders in C#

The SequenceEqual method determines whether two IEnumerable sequences contain the same objects in the same order. There is a simple way to determine whether the lists contain the same objects in different orders: sort the objects and then call SequenceEqual. … Continue reading

Posted in LINQ, lists, miscellany, OOP | Leave a comment

Determine whether two lists contain the same sequences of objects in C#

The IEnumerable interface provides a SequenceEqual method that determines whether two IEnumerable sequences contain the same objects. Normally it uses reference equality so it considers two objects equal only if they refer to the same instance. However, if the objects … Continue reading

Posted in lists, miscellany, OOP | 1 Comment

Draw “ransom note style” text in a RichTextBox in C#

This example is similar to Draw “ransom note style” text where each character has a different font in C# but it writes text into a RichTextBox instead of on a PictureBox. This has several advantages: The code is simpler The … Continue reading

Posted in graphics, strings | Leave a comment

Draw “ransom note style” text where each character has a different font in C#

This example draws each of the characters in a string in a different random font. The program starts by using the following code to create arrays holding font names and brushes from which the program will later randomly select. This … Continue reading

Posted in graphics, strings | Leave a comment

Make a program that finds and removes duplicate files in C#, Part 4 of 4

The last three posts described an application that searches for duplicate files and removes them. The program seems to work fairly well, at least for small test directories. When I tried it on a directory containing around 3,200 files, however, … Continue reading

Posted in algorithms, cryptography, files, system, tools | 1 Comment

Make a program that finds and removes duplicate files in C#, Part 3 of 4

The last two posts described an application that searches for duplicate files and removes them. This post explains how the program removes the files when you click the Delete Selected button. When you click the button, the following code executes. … Continue reading

Posted in algorithms, cryptography, files, system, tools | Leave a comment

Make a program that finds and removes duplicate files in C#, Part 2 of 4

The previous post Make a program that finds and removes duplicate files in C#, Part 1 of 4 explained how the example used a LINQ query that selects files grouped by hash code. This post explains how the program displays … Continue reading

Posted in algorithms, cryptography, files, system, tools | Leave a comment

Make a program that finds and removes duplicate files in C#, Part 1 of 4

This is a fairly complex example so I’m going to cover it’s more interesting pieces in a couple of posts, and I won’t cover some of the less interesting pieces at all. Enter a directory path or click the ellipsis … Continue reading

Posted in algorithms, cryptography, files, system, tools | 1 Comment