.NET: Why aren't Private Abstract methods allowed?(pietschsoft.com)

submitted by crpietschmanncrpietschmann(11.3k) 4 years, 3 months ago

Sometimes when creating base objects you want to create methods that are overridable by object that inherit the base object, but keep the methods from being public. However, the compiler throws an exceptions when you try to define a method as "Private Abstract".

3 comments |category: |Views: 5

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by anandanand(0) 4 years, 3 months ago 0

the very purpose of having a method being declared abstract means that, the derived class must implement that method. So if the derivd class cannot see the method, how can it implement that meathod.
Henceforth an abstract meathod cannot be declared private but you can use protected access specifier instead.

Thanks,
Anand

Reply

posted by yesthatmcgurkyesthatmcgurk(4063) 4 years, 3 months ago 0

Correct. And, in fact, you CAN have protected abstract methods.

Reply

posted by crpietschmanncrpietschmann(11.3k) 4 years, 3 months ago 0

Yes, you can, and if you read my post, you would see that I stated that "Protected Abstract" is what to use in this case.

Reply

information Login or create an account to comment on this story