Object Oriented Programming Basic Concept C

0 votes

As We know

The Default Modifier of Class, Struct, Delegate, Interface, and Enum is Internal.

  1. Enum & Interface members by default are public.

  2. And Class, Struct, and Delegate members by default are private.

  3. Non-derived classes of the same class library can have access to public and internal classes (and public, internal, and protected internal members).

  4. Non-derived classes of different class-library can have access to public classes (public members only).

  5. Derived classes of different class-library can have access to public classes (public, protected, protected-internal members).

Now I want to understand the core concept that why is so that...

Protected members are having more scope than internal?

Dec 9, 2022 in Android by Edureka
• 13,620 points
683 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Protected access specifier allows a child class to access the member variables and member functions of its base class. This way it helps in implementing inheritance. We will discuss this in more detail in the inheritance chapter.

The following is an example showing we have set an protected member variable in Class A.

class A {
   protected int a2 = 87;
}

Now under the derived class when we will try to access the above variable from the derived class object, then it would work fine as shown below −

Example

using System;
class A {
   protected int a2 = 87;
}
class B : A {
   static void Main() {
      A a = new A();
      B b = new B();
      b.a2 = 10;
   }
}

answered Dec 12, 2022 by Edureka
• 12,690 points

edited Mar 5

Related Questions In Android

0 votes
0 answers

How do I turn a C# object into a JSON string in .NET?

I have classes like these: class MyDate { ...READ MORE

Sep 20, 2022 in Android by Edureka
• 13,620 points
550 views
0 votes
0 answers

What are the differences between C, C# and C++ in terms of real-world applications?

As I stated in an earlier article, ...READ MORE

Sep 20, 2022 in Android by Edureka
• 13,620 points
642 views
0 votes
0 answers

What is the difference between C# and .NET?

May I know what is the difference ...READ MORE

Sep 20, 2022 in Android by Edureka
• 13,620 points
449 views
0 votes
0 answers

Roslyn: Convert C# to VB

I have a project that I need ...READ MORE

Dec 9, 2022 in Android by Edureka
• 13,620 points
869 views
0 votes
0 answers

What's the strangest corner case you've seen in C# or .NET?

I have a small collection of puzzles ...READ MORE

Dec 9, 2022 in Android by Edureka
• 13,620 points
429 views
0 votes
0 answers

Convert VB.NET --> C# Projects

Can someone suggest a suitable program that ...READ MORE

Dec 9, 2022 in Android by Edureka
• 13,620 points
592 views
0 votes
1 answer

Object Oriented Programming Basic Concept(C#)

Use this link https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers protected internal: The type or ...READ MORE

answered Jun 17, 2022 in C# by jyoti
• 1,240 points
779 views
0 votes
0 answers

Object Oriented Programming Basic Concept(C#)

We are aware that the default modifier ...READ MORE

Dec 12, 2022 in C# by Roshan
• 300 points
597 views
0 votes
1 answer

Examples of dynamic polymorphism in c#

Check the example of polymorphism below. We ...READ MORE

answered Jun 7, 2022 in C# by pranav
• 2,590 points
961 views
0 votes
1 answer

Authenticate on an ASP.Net Forms Authorization website from a console app

Essentially, we need to record a regular ...READ MORE

answered Sep 20, 2018 in IoT (Internet of Things) by Annie97
• 2,160 points
1,106 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP