Тёмный

Encapsulation in c# | Practical OOPs with c# 

Ravindra Devrani
Подписаться 9 тыс.
Просмотров 10 тыс.
50% 1

four pillars of oops with c#:
This series is an in-depth guide of OOPs concepts. We will implement them with c#.
In this video we will learn about the first pillar.
Encapsulation: General defintion of it "Wrapping the data member and member function in a single unit"
Follow along to understand it more clearly.
▶ Playlist: OOPs concepts with c#: bitly.ws/x7BH
▶Source code: drive.google.c...
.................
Please share it to you circle to support me..
Other links:
▶Angular tutorials and projects: bit.ly/3DitqDp
▶dot net 6 tutorials and projects: bit.ly/3MSrXGX
▶dot net core series: bit.ly/3TolF4i
▶dot net 6 projects: bit.ly/3zpn9ng
.......................................................
connect with me
▶Twitter: / ravi_devrani
▶GitHub: github.com/rd003
▶RU-vid: / @ravindradevrani
..........................................
Become a supporter❤:
You can buy me a coffee: www.buymeacoff...
#oops #oop #encapsulation

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
@connorwalding-c6m
@connorwalding-c6m 2 месяца назад
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 2 месяца назад
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 2 месяца назад
@@ravindradevrani Thanks Ravi, appreciate the clarification! Keepup the great content
@kirank-y4u
@kirank-y4u 11 месяцев назад
Excellent, I have been learning c# from last 6 months, this video made many things clear to me.
@ravindradevrani
@ravindradevrani 11 месяцев назад
Glad to hear✌️
@zargamali8531
@zargamali8531 5 месяцев назад
thank you so much. you explained it very well.
@raveendharmasiri
@raveendharmasiri 5 месяцев назад
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 5 месяцев назад
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.
@otetumooluwaseun3948
@otetumooluwaseun3948 8 месяцев назад
Thanks for the explanation. This is like a 3 in 1 combo
@chimezieokafor-muo4356
@chimezieokafor-muo4356 6 месяцев назад
this is the best explanation I have seen
@trapmixer6349
@trapmixer6349 7 месяцев назад
nice video, easy to understand
@ravindradevrani
@ravindradevrani 5 месяцев назад
Glad to hear that!
@qadeerulla
@qadeerulla Год назад
Excellent videos
@nouchance
@nouchance Год назад
Thank you Ravindra!
@ravindradevrani
@ravindradevrani Год назад
My pleasure
@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: ru-vid.com/group/PLP8UhDwXI7f_1lze_yKyG-51rS9WNAgMG
@AmitYadav-vp6ff
@AmitYadav-vp6ff Год назад
Excellent
@ravindradevrani
@ravindradevrani Год назад
Thank you! Cheers!
Далее
Getters & Setters | C# | Tutorial 28
12:09
Просмотров 193 тыс.
Airpod Through Glass Trick! 😱 #shorts
00:19
Просмотров 1,4 млн
🛑самое главное в жизни!
00:11
Просмотров 132 тыс.
The New Option and Result Types of C#
15:05
Просмотров 70 тыс.
The Flaws of Inheritance
10:01
Просмотров 947 тыс.
ENCAPSULATION IN C# ( URDU / HINDI )
36:38
Просмотров 77 тыс.
What is Span in C# and why you should be using it
15:15
C# polymorphism 🎭
5:11
Просмотров 81 тыс.
Brutally honest advice for new .NET Web Developers
7:19
Don't Use Polly in .NET Directly. Use this instead!
14:58
Interfaces vs Abstract Classes
14:43
Просмотров 15 тыс.