Chapter 1. C# Programming Basics

In This Chapter

Examining keywords

Inspecting statements

Perusing blocks

Reviewing comments

Surveying classes

Investigating variables

Considering data types

Observing operators

Experiencing expressions

In this chapter, you find the basics of writing C# code. If you’ve been browsing around in the book, you’ve already seen plenty of C# code examples, so I won’t start with a basic “Hello World!” program (the way most introductory C# programming books do). Instead, I’ll dive right into the building blocks of C# programs, such as keywords, statements, blocks, and so on.

So jump in and hang on!

Dealing with Keywords

A keyword is a word that has special meaning defined by the C# programming language. In all, C# has 77 keywords. They’re listed in alphabetical order in Table 1-1.

Table 1-1. The C# Keywords

abstract

event

new

struct

as

explicit

null

switch

base

extern

object

this

bool

false

operator

throw

break

finally

out

true

byte

fixed

override

try

case

float

params

typeof

catch

for

private

uint

char

foreach

protected

ulong

checked

goto

public

unchecked

class

if

readonly

unsafe

const

implicit

ref

ushort

continue

in

return

using

decimal

int

sbyte

virtual

default

interface

sealed

volatile

delegate

internal

short

void

do

is

sizeof

while

double

lock

stackalloc

 

else

long

static

 

enum

namespace

string

 
The C# Keywords

Like everything else in C#, keywords are case-sensitive. Thus, if you type If instead of if or For instead of for, the compiler complains about ...

Get ASP.NET 2.0 All-In-One Desk Reference For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.