define our first class (these lines collectively are called a class definition).
C# programs consist of pieces called classes, which are logical groupings of members (e.g.,
methods) that simplify program organization. These methods (which are like functions in
procedural programming languages) perform tasks and return information when the tasks
are completed. A C# program consists of classes and methods created by the programmer
and of preexisting classes found in the Framework Class Library. Throughout this book, we
will teach the reader how to use both techniques in their programs. Every program in C#
consists of at least one class definition that the programmer defines. These classes are
known as programmer-defined classes. In Chapter 8, Object-Based Programming, we discuss
programs that contain multiple programmer-defined classes. The class keyword
begins a class definition in C# and is followed immediately by the class name (Welcome1,
in this example). Keywords (or reserved words) are reserved for use by C# and always consist
of lowercase letters. (A complete table of C# keywords is presented in the next chapter.)
By convention, each word in a class name begins with an uppercase first letter and has an
uppercase letter for each word in the class name (e.g., SampleClassName). The name
of the class is known as an identifier, which is a series of characters consisting of letters,
digits, underscores ( _ ) and “at” symbols (@). Identifiers cannot begin with a digit and
cannot contain spaces. Examples of valid identifiers are Welcome1, _value,
m_inputField1 and button7. The name 7button is not a valid identifier because it
begins with a digit, and the name input field is not a valid identifier because it contains
a space. The “at” character (@) can be used only as the first character in an identifier. C# is
case sensitive—uppercase and lowercase letters are considered different letters, so a1 and
A1 are different identifiers.
C# programs consist of pieces called classes, which are logical groupings of members (e.g.,
methods) that simplify program organization. These methods (which are like functions in
procedural programming languages) perform tasks and return information when the tasks
are completed. A C# program consists of classes and methods created by the programmer
and of preexisting classes found in the Framework Class Library. Throughout this book, we
will teach the reader how to use both techniques in their programs. Every program in C#
consists of at least one class definition that the programmer defines. These classes are
known as programmer-defined classes. In Chapter 8, Object-Based Programming, we discuss
programs that contain multiple programmer-defined classes. The class keyword
begins a class definition in C# and is followed immediately by the class name (Welcome1,
in this example). Keywords (or reserved words) are reserved for use by C# and always consist
of lowercase letters. (A complete table of C# keywords is presented in the next chapter.)
By convention, each word in a class name begins with an uppercase first letter and has an
uppercase letter for each word in the class name (e.g., SampleClassName). The name
of the class is known as an identifier, which is a series of characters consisting of letters,
digits, underscores ( _ ) and “at” symbols (@). Identifiers cannot begin with a digit and
cannot contain spaces. Examples of valid identifiers are Welcome1, _value,
m_inputField1 and button7. The name 7button is not a valid identifier because it
begins with a digit, and the name input field is not a valid identifier because it contains
a space. The “at” character (@) can be used only as the first character in an identifier. C# is
case sensitive—uppercase and lowercase letters are considered different letters, so a1 and
A1 are different identifiers.