Comparing Objects with IComparable and IComparer

There are two useful interfaces that are useful for comparing user-defined objects. These are the IComparable<T> and IComparer<T>interfaces. The IComparable interface is implemented in a class to allow comparison between it and another object. The IComparer<T>is…

Modifying Fonts (An Example)

The following is an example application showing how we can modify a control's Font property using other controls and components. We will use the techniques we have learned earlier to modify the…

Using Fonts

What if you want to change or modify the font of a control in a windows application? The System.Drawing.Font class allows you to create fonts that you can use or assign to…

Reading from an XML File

Reading XML files is a necessary technique to retrieve information from an XML file. Say, for example, you store your configuration settings in an XML file, you can retrieve the…

Writing to an XML File

Using the classes and methods of the XML Document Object Model, we can easily construct an XML document and save it to a file. We will create an application to demonstrate…

XML Document Object Model

The .NET framework offers classes that can read and manipulate XML documents. These classes are located in the System.Xmlnamespace. .NET uses the XML Document Object Model which is a set of classes that…

Extensible Markup Language

Extensible Markup Language (XML) allows you to store data in a text and structured format. It is widely used as a database alternative and for storing application configuration information. XML…

Writing to a Text File

Writing to text files are useful when you want a way of permanent storage of your data. Although databases and XML files are more popular choices, text files are still…

C# System.IO.Path Class

The System.IO.Path class is a utility class that has methods for constructing paths of files and directories. Although you can simply use simple string concatenation and methods, using the Path class makes it easier…

C# System.IO.DirectoryInfo Class

The System.IO.DirectoryInfo class represents a directory in your file system. Its capabilities are similar to the  System.IO.Directory class. You need to create an instance of DirectoryInfo class to make use of its properties…

C# System.IO.Directory Class

The System.IO.Directory class offers methods for creating, deleting, moving, retrieving file lists, and many more. These methods are static so you don't need to create an instance of that class. The following…

C# System.IO.FileInfo Class

The System.IO.FileInfo class is quite similar to the System.IO.File class in that, they are used for the same purpose of manipulating a file. The difference is that FileInfo does not have static methods so you need…