Building strings in memory using the string concatenation operator, the plus sign (+) in C#, causes a few problems. The string class is immutable which means that once a string is created in memory, the size and location of this string value cannot grow or shrink. Thus, when you use the concatenation operator you are creating a new string in a new location in memory and telling the .NET garbage collector to throw away the old string value. This causes the garbage collector to perform extra work and slows down your application. This is where using the StringBuilder class can help you out. In this blog post you learn the basics of using the StringBuilder class.)
In the last blog post you learned to read songs from an exported iTunes XML file. If you have been using iTunes for a long time and have deleted songs, merged songs from other libraries, moved your library from one computer to another, then you may not know it, but there could song files on your hard drive that are no longer in the iTunes library. This blog post shows you how to locate those missing files. To follow along with this blog post, read and follow the instructions in the first blog post on reading songs from iTunes.)
Have you ever wanted to retrieve the list of songs from your iTunes library? Getting songs from iTunes is not easy. In fact, since Apple stopped supplying their COM component for reading from their iTunes library, about the only way to get song data is to export the library into an XML file, then parse the XML. In this blog post you are going to learn to parse the XML using the classes contained in the System.Xml.Linq namespace.)
Yes, we all know reflection is slow, but sometimes it is necessary to use it to satisfy a business requirement in our application. Just like anything, there is a right way and a wrong way to use reflection. Microsoft has made significant improvements in performance over the years for getting and setting properties. This blog post shows you the slow and the fast ways of using reflection. )
Extension methods allow you to add your own custom method to an existing type. This blog posts shows you how to create extension methods.)
Prior to .NET 2.0 when you needed a single method to work with different data types the only way to accomplish this was to pass an 'object' data type to that method. Working with the object data type introduces performance problems and bugs that can occur at runtime. The alternative is to create a new method for each data type that you wished to work with. This blog post introduces you to C# Generics.)
In my last blog post, entitled Caching for Non-Web Applications - Part 1 I introduced you to the MemoryCache class. This class allows you to create a cache for any type of application just like in ASP.NET applications. The great thing about the MemoryCache class is there is no reliance on the System.Web namespace. This means you are free to use the MemoryCache class in any type of application such as Windows Forms, WPF and Windows Services. The last blog post showed you how to add and retrieve data from the cache. This blog post expands on the last one and shows you additional methods you can take advantage of to work with cache data.)
A great feature of ASP.NET applications is the Cache class which allows you to store values that are commonly used. Caching data can avoid round-trips to database servers, which can save a lot of time. Until 2010, there was no good way in a Windows Service, Windows Form or WPF application to cache data except by writing your own class. Enter the MemoryCache class, part of the System.Runtime.Caching namespace. This class allows you to add data to a cache and set a time-out so that data can be removed from memory when it is no longer used. This blog post will show you the basics of using this class)
One of the reasons I love teaching is because of the questions that I get from attendees. I was giving a presentation at DevConnections and was showing a collection of Product objects. When I hovered over the variable that contained the collection, it looked like Figure 2. As you can see in the collection, I have actual product names of my videos from www.pdsa.com/videos being displayed. To get your data to appear in the data tips you must override the ToString() method in your class.)
Many developers use the ConfigurationManager class to retrieve settings from the .Config file of your application. This blog posts shows you how to put your own wrapper class around this class to allow you flexibility in the future.)