- Preparing Your Machine to Work with Strings
- Working with Strings
- Initializing Strings
- Comparing Strings
- Concatenating Strings
- Finding the String Length
- Comparing and Concatenating Strings in the Sample Application
- Creating Strings from Characters
- Using Escape Characters
- Using Literal Strings
- Accessing the String's Characters
- Finding a Substring within a String
- Extracting Part of the String
- Splitting a String
- Joining a String
- Uppercasing and Lowercasing
- Formatting Strings
- Finishing the Sample Application
- Representing Objects as Strings
- Allocating Strings with StringBuilder
Working with Strings
Now that you have set up the database software and installed the database, it's time to start writing the sample application.
To create a test project for this chapter:
Launch Visual Studio .NET. (Start > All Programs > Microsoft Visual Studio .NET > Microsoft Visual Studio .NET).
Select File > New > Project to bring up the New Project dialog.
Under project types on the left side of the New Project window, click the Visual C# projects folder.
Select the ASP.NET Web Application icon and change the name of the application to stringproject (Figure 4.4).
Figure 4.4. The sample application for this chapter will be an ASP.NETWeb application.
Visual Studio will create a new project and open WebForm1.aspx.
Change the form's name to login.aspx. You do that by choosing View > Solution Explorer from the top menu bar.
Right-click on WebForm1.aspx and choose properties. In the property grid change the FileName property from WebForm1.aspx to login.aspx (Figure 4.5).
Figure 4.5. The property grid gives you an easy way to change the filename for your Web page without having to go through Windows Explorer.
Create a form that looks like the form in Figure 4.6. Obviously this is a lot of work to do by hand, so I suggest you enter the HTML directly into the editor instead. Figure 4.7 (next page) shows the HTML necessary to create the form. To enter the HTML directly click the HTML button under the editor's window. As an alternative you could download the skeleton file for this project (see Tips below).
Figure 4.6. The login form lets you enter information that will be used in connecting to the MySQL database. The form has five labels, four textboxes, and one button.
Figure 4.7 The Visual Studio form editor enables you to edit the HTML for the page directly. This HTML is the source for the form in Figure 4.6.
Tips
As with the other projects in this book, building the project isn't necessary for learning the concepts in this chapter.
Skeletons for each project can be downloaded from Peachpit's Web site, http://www.peachpit.com/vqs/csharp.