C# Programing
How a derived class that inherits attributes and behaviors from a base class? Problems with
Protected access modifier.
Solution
A derived class can override a base class member only if base class member is declared as virtual
or abstract. The derived member must use override keyword to explicitly indicate that the
method is intended to participate in virtual invocation.
Protected variables should be avoided because of the following reasons:
1)They tend to lead to some issues. Protected variables generally have some intrinsic invariance
associated with them or else they would be public Inheritors then need to maintain those
properties, which people can violate.
2)If the base class makes too many assumptions about the protected member, or the inheritor is
too flexible with the behavior of the class, it can lead to the base class behavior being modified
by that extension which leads to inheritance for extension rather than composition. Infact tends
to lead to tighter coupling, more violations.

More Related Content

PPTX
Final presentation programming
PPT
session 24_Inheritance.ppt
PPT
Inheritance, Object Oriented Programming
PPTX
Inheritance.pptx
PPTX
B.sc CSIT 2nd semester C++ Unit5
PDF
7 inheritance and polymorphism
PPT
Unit 7 inheritance
PPTX
Inheritance
Final presentation programming
session 24_Inheritance.ppt
Inheritance, Object Oriented Programming
Inheritance.pptx
B.sc CSIT 2nd semester C++ Unit5
7 inheritance and polymorphism
Unit 7 inheritance
Inheritance

Similar to C# ProgramingHow a derived class that inherits attributes and beha.pdf (20)

PDF
INHERITANCE
PPTX
INHERITANCE.pptx
PPT
Inheritance
PPT
week14 (1).ppt
PPT
PPT
Lecturespecial
PPT
inheritance
PDF
lecture 6.pdf
PPT
Inheritance in C++
PPTX
Inheritance
PPT
Lecture 5 inheritance
PDF
Chapter25 inheritance-i
PPSX
PPT
presentation on inheritance concept in c++
PPT
Overview of Object Oriented Programming using C++
ODP
PDF
DOCX
Ganesh groups
PPT
Inheritance
PPT
Inheritance
INHERITANCE
INHERITANCE.pptx
Inheritance
week14 (1).ppt
Lecturespecial
inheritance
lecture 6.pdf
Inheritance in C++
Inheritance
Lecture 5 inheritance
Chapter25 inheritance-i
presentation on inheritance concept in c++
Overview of Object Oriented Programming using C++
Ganesh groups
Inheritance
Inheritance

More from archanaemporium (20)

PDF
Identify a article about a communicable or noncommunicable disease i.pdf
PDF
i safari File Edit View History Bookmarks Window Help 67 D. Thu 101.pdf
PDF
I dont know what is wrong with this roulette program I cant seem.pdf
PDF
I know that water molecules attract each other, but why do water mol.pdf
PDF
How can Internet technologies be involved in improving a process in .pdf
PDF
How many paths are there in a tree with n nodesHow many paths a.pdf
PDF
Hypothesize a way for a virus to evade a host defense & then devise .pdf
PDF
How many ways can letters of the word SINGAPORE be arranged such that.pdf
PDF
Haploid. After is complete, the resulting gametes are haploid. This m.pdf
PDF
FTP and TFTP are primarily file transfer protocols. What is the main.pdf
PDF
Given Starter Fileimport java.util.Arrays; Encapsulates.pdf
PDF
Express the verbal representation for the function f symbolically. M.pdf
PDF
Economic resources have a price above zero because...A. there are .pdf
PDF
DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdf
PDF
Discuss in detail how two different Progressive reformers tackled th.pdf
PDF
Describe the major parts of the nervous system and their functions..pdf
PDF
DEFINE gene enhancer and gene promoter (3-4 sentences each).Sol.pdf
PDF
Cisco Systems, Inc. offers a switching technology known as Multi-Lay.pdf
PDF
Assume that x and y are already defined as being of type int . Write.pdf
PDF
Briefly define cyberterrorism. Define hacktivism. Illustrate example.pdf
Identify a article about a communicable or noncommunicable disease i.pdf
i safari File Edit View History Bookmarks Window Help 67 D. Thu 101.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
I know that water molecules attract each other, but why do water mol.pdf
How can Internet technologies be involved in improving a process in .pdf
How many paths are there in a tree with n nodesHow many paths a.pdf
Hypothesize a way for a virus to evade a host defense & then devise .pdf
How many ways can letters of the word SINGAPORE be arranged such that.pdf
Haploid. After is complete, the resulting gametes are haploid. This m.pdf
FTP and TFTP are primarily file transfer protocols. What is the main.pdf
Given Starter Fileimport java.util.Arrays; Encapsulates.pdf
Express the verbal representation for the function f symbolically. M.pdf
Economic resources have a price above zero because...A. there are .pdf
DOES NOT NEED TO BE ANSWERED UNTIL NOV 13thWords AssignmentRober.pdf
Discuss in detail how two different Progressive reformers tackled th.pdf
Describe the major parts of the nervous system and their functions..pdf
DEFINE gene enhancer and gene promoter (3-4 sentences each).Sol.pdf
Cisco Systems, Inc. offers a switching technology known as Multi-Lay.pdf
Assume that x and y are already defined as being of type int . Write.pdf
Briefly define cyberterrorism. Define hacktivism. Illustrate example.pdf

Recently uploaded (20)

PPTX
What’s under the hood: Parsing standardized learning content for AI
PDF
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
PPTX
Module on health assessment of CHN. pptx
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
Core Concepts of Personalized Learning and Virtual Learning Environments
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
Journal of Dental Science - UDMY (2021).pdf
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
English Textual Question & Ans (12th Class).pdf
PDF
Complications of Minimal Access-Surgery.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
What’s under the hood: Parsing standardized learning content for AI
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
Module on health assessment of CHN. pptx
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Core Concepts of Personalized Learning and Virtual Learning Environments
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
Journal of Dental Science - UDMY (2021).pdf
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Introduction to pro and eukaryotes and differences.pptx
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
Share_Module_2_Power_conflict_and_negotiation.pptx
English Textual Question & Ans (12th Class).pdf
Complications of Minimal Access-Surgery.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
LIFE & LIVING TRILOGY - PART (3) REALITY & MYSTERY.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf

C# ProgramingHow a derived class that inherits attributes and beha.pdf

  • 1. C# Programing How a derived class that inherits attributes and behaviors from a base class? Problems with Protected access modifier. Solution A derived class can override a base class member only if base class member is declared as virtual or abstract. The derived member must use override keyword to explicitly indicate that the method is intended to participate in virtual invocation. Protected variables should be avoided because of the following reasons: 1)They tend to lead to some issues. Protected variables generally have some intrinsic invariance associated with them or else they would be public Inheritors then need to maintain those properties, which people can violate. 2)If the base class makes too many assumptions about the protected member, or the inheritor is too flexible with the behavior of the class, it can lead to the base class behavior being modified by that extension which leads to inheritance for extension rather than composition. Infact tends to lead to tighter coupling, more violations.