O'Reilly logo

Professional C# 2012 and .NET 4.5 by Morgan Skinner, Karli Watson, Jay Glynn, Bill Evjen, Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2

Core C#

WHAT’S IN THIS CHAPTER?

  • Declaring variables
  • Initialization and scope of variables
  • Predefined C# data types
  • Dictating execution flow within a C# program using conditional statements, loops, and jump statements
  • Enumerations
  • Namespaces
  • The Main() method
  • Basic command-line C# compiler options
  • Using System.Console to perform console I/O
  • Using internal comments and documentation features
  • Preprocessor directives
  • Guidelines and conventions for good programming in C#

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

The wrox.com code downloads for this chapter are found at http://www.wrox.com/remtitle.cgi?isbn=1118314425 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • ArgsExample.cs
  • DoubleMain.cs
  • ElseIf.cs
  • First.cs
  • MathClient.cs
  • MathLibrary.cs
  • NestedFor.cs
  • Scope.cs
  • ScopeBad.cs
  • ScopeTest2.cs
  • StringExample.cs
  • Var.cs

FUNDAMENTAL C#

Now that you understand more about what C# can do, you will want to learn how to use it. This chapter gives you a good start in that direction by providing a basic understanding of the fundamentals of C# programming, which is built on in subsequent chapters. By the end of this chapter, you will know enough C# to write simple programs (though without using inheritance or other object-oriented features, which are covered in later chapters).

YOUR FIRST C# PROGRAM

Let’s start by compiling and running the simplest possible C# program — a simple console app consisting of a class that writes a message to the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required