Encapsulation in c# | Practical OOPs with c#

  Рет қаралды 10,413

Ravindra Devrani

Ravindra Devrani

Күн бұрын

Пікірлер: 20
@kumarabhishekranjan4694
@kumarabhishekranjan4694 7 күн бұрын
Nice explanation, easy to understand. This is like buy 1 and get 3. This video helped me in polishing my c# skills. Keep the great work on.
@kirank-y4u
@kirank-y4u Жыл бұрын
Excellent, I have been learning c# from last 6 months, this video made many things clear to me.
@ravindradevrani
@ravindradevrani Жыл бұрын
Glad to hear✌️
@otetumooluwaseun3948
@otetumooluwaseun3948 9 ай бұрын
Thanks for the explanation. This is like a 3 in 1 combo
@chimezieokafor-muo4356
@chimezieokafor-muo4356 8 ай бұрын
this is the best explanation I have seen
@zargamali8531
@zargamali8531 6 ай бұрын
thank you so much. you explained it very well.
@trapmixer6349
@trapmixer6349 8 ай бұрын
nice video, easy to understand
@ravindradevrani
@ravindradevrani 7 ай бұрын
Glad to hear that!
@raveendharmasiri
@raveendharmasiri 7 ай бұрын
everything is good except I wished that you would expalin the concept behind auto implemented properties. So as far I understand. in this case in the backgrond the compiler creates a private field for this property "name" to contain its values and then creates the getter and setter methods for this property. All this happens in the background and you will not be able to see that in the code. That is why we use the -> public String name { get; set; }. Only if you run into the need of writing your own implementation for the setter or getter method, you have to go with the second approach as shown in the video.
@ravindradevrani
@ravindradevrani 7 ай бұрын
Yes everything you have said is absolutely right. C# compiler takes care of implementing private field. User need to focus on auto implemented property only. And it is the default approach of using it these days.
@connorwalding-c6m
@connorwalding-c6m 3 ай бұрын
Hi Ravi, thanks for you video. I am just starting in uni so wanted to know the first file (encapsulation.cs) and the second (encapsulationproperties.cs) are they just two different examples of the same project done in different ways. Really helpful thankyou!
@ravindradevrani
@ravindradevrani 3 ай бұрын
These are the different implementation of same example. Public class Person{ private int age public int GetAge() { return age; } public void SetAge (int age) { if(age>0){ this.age=age; } } public void Display() { /// logic } } It is how encapsulation actually works. That is shown by java. Everything is clear here. We don't want to give direct access of age field to the client. If you don't then any one can enter the negative number there. Instead we give user the getter() and setter() methods to manipulate the age field. This example is enough for explaining encapsulation. If we are using java. But c# have multiple ways to do it. These are the different implementation of same example. Public class Person{ public int Age { get; set { if(value>0) { Age=value; } } public void Display() { /// logic } } Now user can access the Age but can not negative numbers to the age. It is the same thing but with different mechanism. First example is more straightforward. Second example does some magical things. Both are same. Both are protecting your data. But second example is more C#-ish. I hope you understood it. If you are following this OOP series. Then I would recommend you learn polymorphism from this article. It covers more depth. ravindradevrani.medium.com/polymorphism-in-c-ea312521d050
@connorwalding-c6m
@connorwalding-c6m 3 ай бұрын
@@ravindradevrani Thanks Ravi, appreciate the clarification! Keepup the great content
@nouchance
@nouchance 2 жыл бұрын
Thank you Ravindra!
@ravindradevrani
@ravindradevrani 2 жыл бұрын
My pleasure
@qadeerulla
@qadeerulla Жыл бұрын
Excellent videos
@nirjhor8395
@nirjhor8395 Жыл бұрын
need full series of OOps
@ravindradevrani
@ravindradevrani Жыл бұрын
What comes in full series? Check out this c# playlist,may be you will find what you are asking C# complete course: kzbin.info/aero/PLP8UhDwXI7f_1lze_yKyG-51rS9WNAgMG
@AmitYadav-vp6ff
@AmitYadav-vp6ff Жыл бұрын
Excellent
@ravindradevrani
@ravindradevrani Жыл бұрын
Thank you! Cheers!
C# polymorphism 🎭
5:11
Bro Code
Рет қаралды 85 М.
Каха и лужа  #непосредственнокаха
00:15
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 2,1 МЛН
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 16 МЛН
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,3 МЛН
10 Essential Constructors in C# Every Developer Should Know
12:52
Zoran Horvat
Рет қаралды 10 М.
The 4 Pillars of OOP in C# A Comprehensive Guide
5:01
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science Lessons
Рет қаралды 944 М.
#40 Encapsulation in Java
11:42
Telusko
Рет қаралды 199 М.
SQLModel + FastAPI: Say Goodbye to Repetitive Database Code
19:50
Inheritance | C# | Tutorial 31
10:29
Giraffe Academy
Рет қаралды 58 М.
Каха и лужа  #непосредственнокаха
00:15