What are Partial Classes? - C# Programming for Beginners

preview_player
Показать описание
In this video, you will learn what is a partial class and how to work with partial classes. I'll also explain the three main benefits of using partial classes and show you a practical example.

🚀📈💻🔥 If you want to gain more practical experience in building real apps and get career-ready skills, join my Practical Programming Course:
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

📚 Learn programming with these Free E-Books ⬇

CONTENTS:
00:00 - What is partial class
01:54 - Working with partial classes
05:48 - The 3 benefits of using partial classes

Add me on:
Рекомендации по теме
Комментарии
Автор

Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10)

CodeBeauty
Автор

For anybody wanting to learn C# and good principles of programming in general, THIS is the channel and online course. I'm 20% through Saldina's Practical Programming course, and between that course and her YT videos, I've already learned more C# than I have in other courses I've tried. No abstract separation of teaching concepts in isolation. Real-world application development with the concepts explained and applied as the application is being built. Great content! (And no, I'm not being sponsored or paid to say it 🙂)

graytonw
Автор

A common example of the use of partial classes is in forms in a windows form application. The code generated by the designer pertaining to the GUI goes into a "designer.cs" file while the code for functionality driven by the GUI (button clicks, input validation, etc.) goes into the .cs file.

ikasugami
Автор

Hello, I like your way of teaching even, I have used your example to code.

TheKeshav
Автор

Odlicna si, hvala, podrska za dalje☺️

ronaldrussel
Автор

❤ Thank you so much. Wishing you the best.

paarsaJam
Автор

Partial... Readability. If you think having different code segments that make sense together in different files then I'd say you've probably broken the Single Responsibility principle.

douglascaskey
Автор

Heyy. I work with julia and python for numerical optimization in statistics. Recently I have had the doubt on how to use chatgpt appropriately. What is your opinion on this? Is it gonna substitute us (us programmers) some day soon?

santiagozamora
Автор

Great Explanation
I love the way you were kidding randomly

KaramVeer-fo
Автор

There is little point in putting partial classes in a single file, because this defeats the main purpose for which they were introduced.
Partial classes were specifically designed to:

- Separate code into different files for better organization
- Allow automatic code generation while keeping it separate from manually written code
- Facilitate teamwork on different parts of the same class

If you put everything in a single file, you lose these benefits and just add unnecessary complexity.

LuigiZambetti
Автор

Respectfully, I completely disagree with 2 of the 3 benefits you listed.

With regard to organization, if your class is so large that you feel the need to logically split it into multiple files, then your class is doing too much work and should be divided into separate dependencies. Not only does that acheive the desired effect of organizing the code better, it also allows you to name those dependencies according to their usage while simultaneously improving testability. Using partial classes to organize code better is a code smell.

With regards to collaboration, partial classes actively make it more difficult to collaborate by masking internal behavior of classes among multiple files. This makes it more difficult to understand what the code is actually doing, which not only impedes onboarding but also increases the risk of introducing regressions. The concern about producing merge conflicts is overblown given the widespread prevalence of VCS like Git, which simplifies the merge process.

The only good example I've seen of partial classes is with autogenerated code, so I do agree with your third point. But I've seen so many repos with GIGANTIC partial classes split among dozens of files that it would make your head spin. Those same repos need to rely on hacky reflection tricks to make anything testable (assuming they have any code coverage in the first place).

LimitedWard
Автор

bellissima ragazza con un cervello ottimo :) magari le donne fossero tutte come lei veramente donna con qualita ottime di programazione

badrelouariti