Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть C# - Part 25 - What is Difference between Overriding and Hiding? - Tutorial For Beginners

  • parvesh
  • 2024-03-29
  • 44
C# - Part 25 - What is Difference between Overriding and Hiding? - Tutorial For Beginners
  • ok logo

Скачать C# - Part 25 - What is Difference between Overriding and Hiding? - Tutorial For Beginners бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно C# - Part 25 - What is Difference between Overriding and Hiding? - Tutorial For Beginners или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку C# - Part 25 - What is Difference between Overriding and Hiding? - Tutorial For Beginners бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео C# - Part 25 - What is Difference between Overriding and Hiding? - Tutorial For Beginners

In this video we will be learning the difference between method overriding and method hiding (shadowing) in C#

Timestamps
00:00 Intro
00:13 Demo
03:20 Mehtod Overriding
04:08 Method Hiding / Shadowing
04:52 Difference
05:23 Summary

Method Hiding (Shadowing):

Concept: Method hiding, also known as shadowing, occurs when a derived class defines a method with the same name and signature (name and parameter list) as a method in its base class. However, the derived class method implementation is completely independent of the base class method.
Mechanism: The derived class method effectively hides the base class method from direct access when using a reference variable of the derived class type.
Declaration: The derived class method is declared with the `new` keyword to explicitly indicate it's hiding the base class method.
Behavior: When you call the method on a derived class instance, the derived class implementation is executed.
Intention: Method hiding is typically used in less common scenarios, such as:
Disabling inheritance of a specific method in the derived class.
Providing a completely new functionality with the same name in the derived class.
Considerations:
It can lead to unexpected behavior if not used cautiously, especially when working with polymorphism.
The base class method remains accessible if you cast the derived class instance to the base class type (though this is generally discouraged).

Method Overriding:

Concept: Method overriding is a fundamental concept in object-oriented programming that allows a derived class to provide a specialized implementation of a method inherited from its base class. This enables polymorphic behavior, where the actual method called depends on the object's runtime type.
Mechanism: To achieve overriding, the base class method must be declared as `virtual` (or `abstract` if the base class is abstract), and the derived class method must be declared as `override`. This ensures the compiler verifies that the signatures and return types match.
Declaration: The base class method uses the `virtual` keyword, and the derived class method uses the `override` keyword.
Behavior: When you call the overridden method on a derived class instance (or even a base class reference variable pointing to a derived class instance), the derived class implementation is executed due to polymorphism (dynamic method dispatch).
Intention: Method overriding is a powerful technique for:
Extending or modifying inherited behavior in derived classes.
Implementing polymorphism to achieve flexible and dynamic method calls.
Considerations:
It's crucial to maintain the base class method's contract (return type and parameter behavior) in the overridden method to avoid breaking existing code.


Choosing Between Hiding and Overriding:

Method hiding is generally less preferred due to its potential for surprising behavior. Use it cautiously and only when you explicitly intend to prevent inheritance of the base class method or provide a completely new functionality with the same name.
Method overriding is the recommended approach for extending or modifying inherited behavior in a way that adheres to the established contract (return type and parameter behavior) of the base class method. It leverages polymorphism for flexible method calls based on the object's runtime type.

By understanding the distinct purposes and implications of method hiding and method overriding, you can effectively implement inheritance and polymorphism in your C# applications.

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]