Classes Fundamentals 99materials
Introduction:
To use a variable, we can declare it using either var keyword or a known and simple data type. For example, we can use an integer to declare a variable that represented the number of bedrooms of a house. Here is an example:
Introduction:
To use a variable, we can declare it using either var keyword or a known and simple data type. For example, we can use an integer to declare a variable that represented the number of bedrooms of a house. Here is an example:
class Program
{
static void Main()
{
int bedrooms = 3;
}
}
As opposed to a simple variable, in C#, you can use one or more variables to create a more complete or complex object.A class is a technique of using one or a group of variables to be used as a foundation for a more detailed variable. When creating a class, you start with the class keyword followed by a name and its body delimited by curly brackets.Application: Introducing Classes 99materialsNaming a Class 99materials
- Start Microsoft Visual Studio
- To create a new application, on the main menu, click File -> New Project
- In the middle list, click Empty Project
- Change the Name to DepartmentStore1
- Click OK
Like a variable, a class must have a name. The name primarily follows the same rules as the variables. You can then add your own rules. In our lessons:
- If the name of a class is in one word, the first letter will be in uppercase. Examples are Identification, Vehicle, or Student
- If the name of a class is a combination of words, the first letter of each word will be in uppercase. Examples are DrivingRecord, GeometricShape, or SocialSecurityInformation.
Managing Classes 99materials
Introduction
Microsoft Visual Studio provides many tools and visual objects used to manage classes of an application.
The studio makes it possible to conveniently rename a class (or one of its members) or to easily navigate to a
class.
The Class View
Probably the best window to manage classes is called the Class View. To get the Class View:
The Class View is made of six sections. The title bar and the use of the Class View follow the same
description as for the Solution Explorer:
The Class View New Folder button allows you to create and add a new folder to the project. The Back and
the Forward buttons allow you to navigate among the classes.
Under the toolbar, there is another bar made of a combo box and a button. These allow you to search.
The body of the Class View is made of two sections. The first node of the upper section displays the
name of the project. Under the project node, the names of classes display. The bottom section of the Class View is used to display the members of a class. To see the members of a class, you can click it in the top window. Here is an example:
|






No comments:
Post a Comment