What is OOP (Object Oriented Programming)?
Working with Classes and Objects
Class Members
Access Modifiers - Encapsulation
It's all about learning, it's for fresher, intermediate, and for experienced to brush up the base.
Friday, April 2, 2021
C# Object Oriented Programming 101
Tuesday, March 30, 2021
Access Modifiers - Encapsulation
We have seen Private, Public in our previous examples or posts. These are access modifiers now let's understand different types of Access Modifiers.
Access Modifiers helps to achieve encapsulation,
Public Accessible to all classes
Private Only accessible to the same class
Protected It is accessible within the same class and its inherited classes
Internal It is accessible within its own assembly, but not from other assembly
We will be going in details to upcoming topic of Inheritance where in broad level we can see the usage of given access modifiers
Class Car
{
private string color;
public string make";
}
Class Program
{
static void Main(string[] args)
{
Car myCar = new Car();
myCar.color = "Red"; //This will throw error of inaccesible due to its protection level
myCar.make = "Audi"; //This is allowed
}
}
Encapsulation can be achieved through modifiers, means you can hide sensitive information from clients.
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...
-
Design Patterns In software engineering, design patterns are time-tested solutions that mean general problems that are frequent to happen ...
-
I am trying to explain C# with Object-Oriented Programming in a much easy language with examples. To help out to clear basic thumb rules and...
-
I would request you to review my previous blog post for a basic understanding of Object Oriented Programming (To Read Click Me) From the pre...