Examining Your First Program
The single greatest challenge when learning to program is that you must learn everything before you can learn anything. Even this simple Hello World program uses many features of the language that we will discuss in coming chapters, including classes, namespaces, statements, static methods, objects, strings, blocks, and libraries.
It’s as though you were learning to drive a car. You must learn to steer, accelerate, brake, and understand the flow of traffic. Right now, we’re going to get you out on the highway and just let you steer for a while. Over time, you’ll learn how to speed up and slow down. Along the way, you’ll learn to set the radio and adjust the heat so that you’ll be more comfortable. In no time you’ll be driving, and then won’t your parents begin to worry.
Hang on tight; we’re going to zip through this quickly and come back to the details in subsequent chapters.
The first four lines in the program are called using statements:
using System; using System.Collections.Generic; using System.Linq; using System.Text;
Visual Studio inserted these for you automatically. These using statements provide a shorthand way to access various parts of the .NET Framework that you might want to use in your program. In fact, you used only the first one this time around, but it doesn’t hurt anything to have the others there. We’ll discuss the System part in just a minute.
The next line in the program defines a namespace:
namespace HelloWorld
{You will create many ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access