ADBRITE ads links
You are here: CodeIdol.com > C# > Learning C# 2005 > Classes And Objects
Learning C# 2005
| 7.1. Defining Classes
When you define a new class, you define the characteristics of all objects of that class, as well as their behaviors. For example, if you create your own windowing operating system, you might want to create screen widge...
|
|
| 7.2. Method Arguments
The behavior of a class is defined by the methods of that class. To make your methods as flexible as possible, you can define parameters
: information passed into the method when the method is invoked. Thus, ...
|
|
| 7.3. Constructors
In Example 7-1, notice that the statement that creates the Time object looks as though it is invoking a Time( ) method:
Time timeObject = new Time( );
In fact, a member method is invoked w...
|
|
| 7.4. Initializers
It is possible to initialize the values of member variables in an initializer, instead of having to do so in the constructor. You create an initializer by assigning an initial value to a class member:
pri...
|
|
| 7.5. The this Keyword
The keyword this refers to the current instance of an object. The this reference is a hidden parameter in every nonstatic method of a class (static methods are discussed later in this chapter). There are three way...
|
|
| 7.6. Static and Instance Members
The fields, properties, and methods of a class can be either instance members
or static members
. Instance members are associated with instances of a type, while static members are associated with ...
|
|
| 7.7. Destroying Objects
Unlike many other programming languages (C, C++, Pascal, etc.), C# provides garbage collection
. Your objects are destroyed after you are done with them. You do not need to worry about cleaning ...
|
|
| 7.8. Memory Allocation: The Stack Versus the Heap
Objects created within methods are called local
variables
. They are local to the method, as opposed to belonging to the object, as member variables do. The object is c...
|
|
| 7.9. Summary
When you define a new class, you declare its name with the class keyword, and then define its methods, fields, delegates, events, and properties.To instantiate an object, you declare the name of the class, followed by an identifier...
|
|
| 7.10. Quiz
Question 71.
What is the difference between a class and an object?
Question 72.
Where are reference types created?
Question 73.
Where are value types created?
Question 74.
What does the keyword private do?
Question 75....
|
|
You are here: CodeIdol.com > C# > Learning C# 2005 > Classes And Objects
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|