|
||||||||
Because, in my opinion, the best way to learn programming is to write programs, the first part of this book is designed to get you up and running with Visual C# 2005. Chapter 1 is titled "Getting Started with Your First Windows Program." The first step in programming in Visual C# 2005 is to obtain and install it. This chapter advises you how. The chapter then shows you how you can create your first Visual C# 2005 project. This chapter concludes by explaining core concepts such as what a computer program is, what a programming language is, and how your code is translated for the computer.Chapter 1 shows you how to create a working Windows application without having to write any code. However, you will need to write code for even the simplest program. Therefore, Chapter 2, "Writing Your First Code," is about just that. This chapter explains key programming concepts, such as classes, objects, and properties, as well as gives you a tour of the Visual C# 2005 Integrated Development Environment (IDE). Chapters 1 and 2 focus on the form, perhaps the most important part of a Windows application's graphical user interface (GUI). However, a form cannot possibly meet all the requirements of a Windows application. For example, the form does not have the functionality to permit the typing of text, listing of data, selecting of choices, and so forth. Chapter 3, titled "Controls," explains how to add controls to your form and manipulate their properties. This chapter then uses a project to demonstrate how you can use a control's events in an application. Now that you are up and running with Visual C# 2005, the next part of this book covers the building blocks of your programs—variables, data types and operators—starting with Chapter 4, "Storing Information—Data Types and Variables." Most computer programs store information, or data. Data comes in different varieties, such as numeric or text. The type of information, whether numeric, text, or Boolean, is referred to as the data type, and often is stored in a variable, which not only reserves the amount of memory necessary to store information, but also provides you with a name by which that information later may be retrieved. As a former professional chess player, I have marveled at the ability of chess computers to play world champions on even terms. The reason the chess computers have this ability is because they can calculate far more quickly and accurately than we can. Chapter 5, "Letting the Program Do the Math—Arithmetic Operators," covers arithmetic operators, which we use in code to harness the computer's calculating capabilities. Now that we have covered the programming building blocks, it is time to use them in the next part of this book, which concerns controlling the flow of your program. As programs become more sophisticated, they often branch in two or more directions based on whether a condition is true or false. For example, although a calculator program would use the arithmetic operators you learn about in Chapter 5, your program first needs to determine whether the user has chosen addition, subtraction, multiplication, or division before performing the indicated arithmetic operation. Chapters 6, "Making Comparisons—Comparison and Logical Operators," introduces comparison and logical operators, which are useful in determining a user's choice. Chapter 7, "Making Choices—if and switch Case Control Structures," introduces the if and switch statements, which are used to direct the path the code will follow based on the user's choice. When you were a child, your parents may have told you not to repeat yourself. However, sometimes your code needs to repeat itself. For example, if an application user enters invalid data, your code may continue to ask the user whether they want to retry or quit until the user either enters valid data or quits. Chapter 8, "Repeating Yourself—Loops and Arrays," introduces loops, which are used to repeat code execution until a condition is no longer true. This book is a few hundred pages long. Imagine how much harder this book would be to understand if it consisted of only one, very long chapter, rather than being divided into multiple chapters, with each one divided into sections? Chapter 9, "Organizing Your Code with Methods," shows you how you similarly can divide up your code into separate methods. This has advantages in addition to making your code easier to understand. For example, if a method performs a specific task, such as sending output to a printer, which is performed several times in a program, you only need to write once in a method the code necessary to send output to the printer. The next part of this ebook focuses on the graphical user interface (GUI), starting with Chapter 10, "Helper Forms." Up until now, our applications have had one form that serves as the main application window. This one form may be sufficient for a simple application, but as your applications become more sophisticated, the main application form will become unable to perform all the tasks required by the application and need help from other forms. This chapter shows you how to create and use two dialog forms that will be workhorses in your applications—a built-in dialog form, the message box, and programmer-designed dialog forms. Although these dialog forms are helpful, they also present programming challenges involving communication between the main form and the dialog form. Application users give commands to an application, such as to open, save, or close a file, print a document, and so on, through the GUI of the application. Chapter 11, "Menus," and Chapter 12, "Toolbars," cover the three most common GUI elements through which application users give commands to an application: the menu, shortcut or context menus, and toolbars. Additionally, commands such as Cut, Copy, and Paste often may be duplicated in a menu, a context menu, and a toolbar, providing the application user with the convenience of three different ways to perform the same command. However, you don't want to write the same code three times, so these chapters show you how to connect corresponding items in menus, context menus, and toolbars so they each execute the same code. When I was finished writing this book for the evening, I closed Microsoft Word, and maybe even shut down my computer. Of course, the next evening I did not have to start over; what I had written the previous evening had been saved. However, up until now the programs in this book don't save data so that it will be available even after the applications exit. The next part of this ebook shows you how to save data. Chapter 13, "Accessing Text Files," explains how to write code that reads from and writes to a text file. This chapter also shows you how to add to your program Open and Save dialog boxes, such as those used in sophisticated programs like Microsoft Word, so you can open a text file to read from it, and save to a text file to write to it. Chapter 14, "Databases," explains how to write programs that access information stored in a database. Throughout this book we have been writing Windows applications, which to be sure are heavily used. However, many of us are interacting ever more frequently with the subject of Chapter 15, "Web Applications." This chapter shows you how to create a web application that displays information from a database, similar to the Windows application you created in Chapter 14. Download free ebook for c#: Visual C# 2005 Demystified-A Self-Teaching Guide
|
| More free ebooks | |
Free programing ebooks
Because, in my opinion, the best way to learn programming is to write programs, the first part of this book is designed to get you up and running with Visual C# 2005. Chapter 1 is titled "Getting Started with Your First Windows Program." The first step in programming in Visual C# 2005 is to obtain and install it. This chapter advises you how. The chapter then shows you how you can create your first Visual C# 2005 project. This chapter concludes by explaining core concepts such as what a computer program is, what a programming language is, and how your code is translated for the computer.