Lesson 13 Teaching Work With Classes in #C

This is our Lesson 13 Teaching work with classes in #c. In this course, we will introduce you to the CLASS class concept in #c and how to use it. Also, how to define classes in a programme and how to decide their characteristics and methods.

Work With Classes in #C

First and foremost, we’ll discuss the concept of class. #c is a class. A class is a group of properties, variables, and methods that are linked to one another.

Define a class of mentioned qualities and make a copy of it to use in the software code that instructs the object or Object.

You can use the variables and methods of the class if it is created on an object or an object. Any number you require can be an object or an object from the class Make, which you can utilize in various places throughout the application code.

The concept of the goal or Oriented Object is a broad category that will be covered in later classes in this lesson.

You saw that from a class in the application code in the introduction section of the training #C and in the World Hello example.

Almost everything was written in #c and was based on classes. We’re going to expand and familiarize yourself with a variety of facilities in this lesson’s code:

using System;
namespace ConsoleApplication1
{
 class Program
 {
 static void Main(string[] args)
 {
 Car car;
car = new Car("Red");
 Console.WriteLine(car.Describe());
 car = new Car("Green");
 Console.WriteLine(car.Describe());
 Console.ReadLine();
 }
 }
 class Car
 {
 private string color;
 public Car(string color)
 {
 this.color = color;
 }
 public string Describe()
 {
 return "This car is " + Color;
31
 }
 public string Color
 {
 get { return color; }
 set { color = value; }
 }
 }
}

In the preceding code, you can see that we’ve created a new class named COR. We placed this new class alongside the Program Class in the original application file for convenience, but you can create it elsewhere in your file.

Color is a variable in CAR that is used to determine the colour of the car. Because the COLOR property is defined as private or private, functions and classes outside of the car function do not have direct access to it.

Only the functions and methods of CAR class Can have direct access to the Calor property.

Note: If the function or calse outside of the Car wants to access private property or private called Color Access.

Have a property to use a property for this purpose. A PROPERTY called COLOR at the end CAR code is defined to read and write this property and to other classes and Program functions allow access to it.

A constructive function or function Object() { [native code] } is likewise available in the CAR class. When the building of an object from a class is completed, the function Object() { [native code] } function is called.

A parameter for initialization is available in the car manufacturer function. The initial automobile object (Red (red)) has a large red colour.

As a result, the red colour will be the default for every object of the CAR class that made To be. To demonstrate the accuracy of this problem, the DESCRIBE function has the name of any item or object with its colour value in the badge’s output.

To teach concepts such as properties (properties), constructive function (function Object() { [native code] }), and Square vision (visibility) in the following sections.

%d bloggers like this: