© Radek Vystavěl 2017

Radek Vystavěl, C# Programming for Absolute Beginners, https://doi.org/10.1007/978-1-4842-3318-4_1

1. Getting Ready

Radek Vystavěl

(1)Ondřjov, Czech Republic

Welcome, dear reader, as you begin your journey to learn programming! Computers, tablets, mobile phones, and many other electronic devices are programmable and will do exactly what a human programmer tells them to do.

Programming is a world based entirely on logic. In this respect, it is quite unique among human activities. If you like logic—for example, you like solving puzzles or you are accustomed to searching for the meaningful order around you—then you will love programming.

C# Language

In this book, you will create some real programs, and for this purpose, you need to learn a programming language, which is what gives the computer its instructions. Programming languages provide the interaction between computers and humans. They are strict enough so that absolutely dumb computers can understand them, and yet they are human enough so that programmers can write code using them.

Over time, many programming languages have been created, and many are in use today. Each language has its virtues and drawbacks.

For this book, I have chosen the C# programming language, which is my number-one language both for professional development and for teaching. It’s about 15 years old, which means its creators could avoid the known flaws of older languages when developing it. In addition, it is now a time-proven language, not to be readily replaced by some new fashion.

C# is actually the flagship language of Microsoft. It is quite universal—you can use it to write a variety of programs ranging from traditional console and desktop applications through web sites and services to mobile development, both for business and for entertainment. Originally born on Windows, it has been quickly spreading onto other platforms in recent years—such as Linux and Mac and Android and iOS.

I hope you will have a good time with it and you will find many uses for it in your future professional/hobby life!

Who This Book For

The book is primarily intended for those who have no or only a limited knowledge of programming. To get the most from this book, you should be skillful with computers—you should be able to install a program, know what a file or a folder is, and so on.

However, because of the book’s deep coverage of the topics included, you may also benefit from the book if you are an intermediate programmer or someone who has already mastered another programming language and want to start with C#. You will simply proceed faster through the book than absolute beginners.

How the Book Differs from Others

I wrote this book based on my 15 years of experience teaching programming to various groups of students, teachers, hobbyists, and others. For many of them, it was their first encounter with the subject. I watched them closely while working, and over the years I have accumulated a fair amount of information about how people learn, what is easy for them, and what requires more attention.

In this book, you will benefit from this knowledge. The book differs from similar ones mostly in the following aspects:

  • The pace of explanations—i.e., the speed of proceeding to new topics—is appropriately slow so that you do not get lost shortly after having started. A common fallacy of expert authors is to consider beginner stuff as trivial. Actually, it is trivial—for them. But not for the reader. I have made considerable effort to avoid this and to spend enough time on things considered easy by the initiated.

  • I believe that for you to successfully grasp all the new ideas, you need to see them used repeatedly in slightly different situations, and this is what you find here. The examples are written so that you proceed in small steps, reinforcing what you already know and always adding a little bit of new information or perspective.

  • The multitude of examples allows me to go quite deep into the subject even while staying at the beginner level. Many starter books show a new notion through one or two textbook examples and move on. This is not so here. The examples chosen stem from real programming. They often represent the core of various situations I have found myself in when developing real-world software. I cover the core topics distilled to an elementary level.

  • I have authored several programming books in the Czech language and have found that many readers preferred the coding examples over the explanatory text. This probably reflects our modern times of information overload. That is why I have written this book using a concise, task-oriented approach. You will find a minimum of talking and a maximum of action here. Enjoy it!

How to Work with the Book

Before I start telling you how to prepare your computer, here are some tips on how you might work with the book to get maximum usefulness out of it:

  • The book contains many exercises. These are not tasks for practicing what you have already learned. These tasks constitute the main instructions of the book. This means you are not supposed to try to solve them after reading what the task is. What you are supposed to do is to read what the task is about, see its illustrative screenshots, and go immediately to study its solution.

  • You should not just read the solutions. You are strongly encouraged to type them on your computer and get them working. The exercises will have much greater impact on your understanding if you try everything yourself.

  • In case you cannot get some exercise working, you can always check the accompanying source codes at https://github.com/apress/charp-programming-for-absolute-begs . Also, you might want to visit my website at http://moderniprogramovani.cz/en/ .

  • In each task, try to understand the logic of its solution. Also, it is helpful to try your own modifications of the tasks. Do not be afraid to play with the code. It is not a chemical lab; you will not blow up your house!

  • I have included lots of comments in the solutions. Actually, each logical part of the code is prepended by a blank line and a comment explaining its purpose. Please pay close attention to these comments; they are the primary hints situated exactly in the places they are explaining. Only the longer explanations I have placed outside of the code, into the regular text of the book.

  • At the end of each chapter, you can relax and read its summary. You can then compare it to what you learned about the topics covered before moving on to the next chapter.

What to Install on Your Computer

That’s enough introduction. Let’s proceed to how to get ready—or, rather, how you should get your computer ready.

Development Environment

To work with this book, you need a single program installed on your computer—a so-called integrated development environment (IDE ).

What is an IDE? Well, to perform any activity on a computer, you need the appropriate software. To write text, you use a word processor; to view a web page, you use a browser; and so on. In the same way, to create programs, you use specialized software that facilitates programming, and this software is the development environment. In other words, it is a “program for programming.”

It is often called an “integrated” development environment because it brings together all the programmer’s activities—writing the code using smart editor, building the program into a computer-ready form, launching and testing it, peeking into computer’s memory, and so on—into one place with tools to help.

Visual Studio

For C#, the number-one development environment is Visual Studio . At the time of writing, the latest version is 2017, and it is available in a free-of-charge edition called Community (see Figure 1-1). This is what I will use throughout the book, and in a minute you are going to learn how to install it.

A458464_1_En_1_Fig1_HTML.jpg
Figure 1-1 Visual Studio Community

Windows Versions

Visual Studio requires the Windows operating system. If you perform a web search for Visual Studio system requirements, you will find the Windows versions supported (see Figure 1-2).

A458464_1_En_1_Fig2_HTML.jpg
Figure 1-2 Windows versions supported

As you can see, you do not need to have the latest and greatest version of Windows. As of August 2017, you can even have Windows 7 with Service Pack 1 installed .

Non-Windows Operating Systems

If you do not have the Windows operating system on your computer, you will be happy to hear about the Visual Studio Code development environment. This is a free-of-charge, multiplatform IDE running also on Linux or Mac, allowing you to program in C# on these systems.

In this book’s examples, I will use Visual Studio Community 2017 installed on Windows. I recommend you do the same. If this is not feasible for you, use Visual Studio Code, taking into account that some things might be a little different from what you see in the book.

Installation

Now you know what to install —Visual Studio Community 2017—so, please, go ahead! Point your web browser to http://visualstudio.com and look for something like “Download Community 2017” on the page. Click the button or link, and the installer starts downloading.

During installation, a screen with the different components you can select appears (see Figure 1-3).

A458464_1_En_1_Fig3_HTML.jpg
Figure 1-3 Installing Visual Studio

Be sure to select “.NET desktop development” and click the Install button. After that, the installation should run smoothly.

Free Registration

After you have installed Visual Studio , you should register your copy (free of charge) the first time you launch it. On the appropriate screen, click the “Sign in” button and enter your Microsoft account credentials. If you do not have a Microsoft account yet, just click the “Sign up” link to get one (see Figure 1-4).

A458464_1_En_1_Fig4_HTML.jpg
Figure 1-4 Registrating your copy of Visual Studio

If you skip this step during the first launch of Visual Studio, you can register later by selecting Help ➤ Register Product in Visual Studio.

Summary

In this book, you are going to study programming and, specifically, the C# programming language. You will learn to code in C# via many practical exercises that will guide you toward more and more complex topics. To be able to follow along with the exercises, you should prepare your computer in the following ways:

  • You need a computer with the Windows operating system (at least Windows 7 with Service Pack 1).

  • You need to install an appropriate development environment. In this book, I will work with the free Visual Studio Community 2017.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.183.10