Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 511 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
511
Dung lượng
8,76 MB
Nội dung
this print for content only—size & color not accurate spine = 0.969" 512 page count Books for professionals By professionals ® Beginning C# 2008: From Novice to Professional Dear Reader, This book is about showing you how to write good code in C# 2008, even if you have never programmed before. Writing good code can be a challenge—there are so many options, especially in C# 2008. So if you want to really get the most from a programming language, you need to know which features work best in which situations and understand their strengths and weaknesses. It is this understanding that makes the difference between coding and coding well. With this in mind, I have written Beginning C# 2008 to teach you how to use the C# programming language to solve problems. From the earliest chapters, and from the first introductory concepts that you’ll discover about C#, you will be looking at real programming challenges and learning how C# can be used to solve them. As you progress with me through the book, these problems become increasingly more involved and interesting, as I show you how C# features can interact to achieve the programming results you want. By the time you’ve finished reading Beginning C# 2008 and worked through the sample exercises, you’ll be a confident and very competent C# programmer. You will still have many new explorations of the huge .NET Framework API to look forward to in your programming, but you will have a firm foundation for your future career in C#, and you will know exactly where to find all the infor- mation you need to progress confidently with your C# projects. Christian Gross Author of How to Code .NET Ajax and REST Recipes Ajax Patterns and Best Practices Foundations of Object- Oriented Programming Using .NET 2.0 Patterns A Programmer’s Introduction to Windows DNA US $39.99 Shelve in Programming/C# User level: Beginner–Intermediate Gross C# 2008 The eXperT’s Voice ® in .neT Beginning C# 2008 From Novice to Professional cyan MaGenTa yelloW Black panTone 123 c Christian Gross Companion eBook Available THE APRESS ROADMAP Pro ASP.NET 3.5 with C# 2008 Pro LINQ: Object Relational Modelling in C# 2008 Pro WPF in C# Accelerated C# 2008 Beginning C# 2008 Pro LINQ Pro C# 2008 and the .NET 3.5 Platform www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN-13: 978-1-59059-869-6 ISBN-10: 1-59059-869-5 9 781590 598696 5 3 9 9 9 Beginning [...]... we’ll add a button that, when clicked, will display “hello, world” in a text box First, you need to add the Button control to the form Double-click Form1.cs in the Solution Explorer to display a blank form Then click the Toolbox tab to access the controls Click Button, and then click the form to place the button on the form These steps are illustrated in Figure 1-5 Figure 1-5 Adding a button to the form... techniques to use when This book is here to answer your questions This book is not a reference to all of the features of the C# programming language I don’t explain the esoteric C# features I stick to the C# programming features that you will use day in and day out That does not mean that you will be missing certain C# programming language constructs, because I have covered all of the major features To get... you a programmer who understands what needs to be done when writing robust, stable, and maintainable C# applications In this chapter, you’ll get started by acquiring the tools you need to develop C# applications and taking those tools for a test spin Along the way, you’ll create a couple C# applications Downloading and Installing the Tools Getting started with C# 3.0, you’re probably really excited about... 9:51 AM Page 3 CHAPTER 1 ■ READY, STEADY, GO! Figure 1-1 Selecting Visual C# 2008 Express Edition 6 A dialog box appears, asking where you want to store the downloaded file The file that you are downloading is a small bootstrap file, which you’ll use to begin the actual installation of the Visual C# Express IDE Choose to save the file on the desktop These steps can be carried out very quickly, probably... Visual C# Express automatically generates some source code for it Double-click Program.cs in the Solution Explorer to see the generated code The source code shown in Figure 1-3 will appear in the area to the left of the Solution Explorer ■ Note To shift between the user interface and generated code, right-click Form1.cs in the Solution Explorer A submenu appears with the options View Code (to see the... environment Now we need to figure out what we actually need We have too many options— too many ways to solve the same problem What I am trying to do with this book is the same thing that Charles did for me when I first started out, and that was to help me figure out what I needed to write code This book is about explaining the C# programming language in the context of solving problems C# has become a sophisticated... Designer (to see the user interface) Figure 1-3 Source code pieces in a C# file The elements labeled in Figure 1-3 represent the essence of the C# source code that you’ll be writing You’ll learn about them throughout this book For now, the main elements to note are as follows: Class: An organizational unit that groups related code together This grouping is much more specific than a solution or a project To. .. good practice to save your changes To save the project, follow these steps: 1 Highlight the solution name in the Solution Explorer 2 Select File ➤ Save ThreeExamples.sln 3 Notice that Visual C# Express wants to save the solution using the old Example1 name, not the new solution name (ThreeExamples) To save the new solution name to the hard disk, you need to yet again change Example1 to ThreeExamples... application by clicking the window’s close button Figure 1-4 illustrates the process 7 8695ch01.qxd 8 10/16/07 9:51 AM Page 8 CHAPTER 1 ■ READY, STEADY, GO! Figure 1-4 Running an application Running the application enables you to see what it does When you run an application though the IDE, it is identical to a user clicking to start the application from the desktop In this example, Example1 displays an... (http://msdn2.microsoft.com/en-us/vstudio/ default.aspx) for more information If you already have Visual Studio 2008 Professional, you can use that for the examples in this book That edition can do everything that Visual C# Express can do, and in fact, has many more options ■Note I personally use Visual Studio Standard or Professional in combination with other tools such as X-develop and JustCode! from Omnicore (http://www.omnicore.com), . page count Books for professionals By professionals ® Beginning C# 2008: From Novice to Professional Dear Reader, This book is about showing you how to write good code in C# 2008, even if you have. 97 8-1 -5 905 9-8 6 9-6 ISBN-10: 1-5 905 9-8 6 9-5 9 781590 598696 5 3 9 9 9 Beginning