First, read over the text and the code shown on the web page. If you only need a small piece of code, that may be all you need. For example, if you don’t remember how to draw lines with custom dash patterns, then the post Draw lines with custom dash patterns in C# may be enough to refresh your memory and get the job done.
Second, if the text of the post isn’t enough by itself, download the example! The text and code on the web page only describes the most interesting or confusing pieces of the example program and often that’s not enough to get a program to actually run. Often the downloadable example includes setup code, code that supports the main features, and properties and controls that are defined on the main form.
To see the whole example program, click the Download button at the bottom of the post.
Third, if you do download the example program, unzip it! Windows Explorer is smart enough to pretend a zip file is a normal directory, but Visual Studio isn’t that smart. If you use Windows Explorer to dig into the zip file, you can double-click on the .sln file and Visual Studio will start. Unfortunately Visual Studio gets confused and displays an uninformative error message such as the following.
A similar problem may occur if you manage to open a project but then get permission errors or errors writing files. Either you don’t have permission for Visual Studio to write temporary files in the directory where you opened the project, or you managed to open the project inside the zip file and Visual Studio cannot figure out how to write the files inside it. In this case, make sure you have unzipped the file and make sure you have permission to write in your current directory.
Finally, make sure you have a new enough version of Visual Studio. I normally post examples in an older version of Visual Studio so you can open them in any newer version. Most of the examples were built in Visual Studio 2008 and any of the newer versions should be able to open them. If you’re using an even older version such as Visual Studio 2005, you might want to upgrade. You can download Visual Studio 2017 Community Edition for free here.