
174Microsoft Visual Studio 2010: A Beginner’s Guide
representation of the data where any characters that don’t have a readable representation appear as dots. You can see “.J.e.a.n.” on the first line of the third column. .NET characters are
You can see that I’ve highlighted the 00 20 at the end of the first line of the second column in Figure
Fixing the First Bug
While you might have bad data and it might not be your fault, the prospect of fixing the problem by fixing the data source is often illusive, meaning that you need to apply a fix in your code. In this section, we’ll apply a fix. However, we’ll put a convoluted twist in the solution where we discover a new bug when fixing the first. The purpose is twofold: to illustrate the
1.Press
2.Implement a fix by commenting out the contents of the foreach loop and replacing with code that protects against extraneous spaces in the data, as follows:
C#:
var firstName = cust.FirstName.Trim(); var lastName = cust.LastName.Trim();
if (searchName == cust.FirstName)