Monday, March 29, 2021

Class Members

 Class is a combination of its Fields and Methods and that is referred to Class Members

Class Car
{
        String Color;
        String Power;     

        Void Speed()
        {
            //Method Definition to calculate Max speed based on it's specifications
        }

}

Class Car consist of its member Color and Power and Speed() is a method. You can utilize the same object as many times as you need following the program need. Below is how you can create an object and initialize its members to required specification.

Car carObject = new Car(); //Creating Object of Class Car
carObject.Color = "Blue"; //Initializing fields
carObject.Power = 1000; //Initializing fields
carObject.Speed(); //Method Calling

There are acess modifiers used to restrict the usage of Class members, we will see it in upcoming post. Please stay connected. 

No comments:

Post a Comment

C# Interview Prep: 100 Common Questions for 0-3 Years Experience

Common C# Interview Questions  Basics of C# Language: What is C#? C# (pronounced C sharp) is a modern, object-oriented programming language...