Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



.NET: Why aren't Private Abstract methods allowed?

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".

Why doesn't the compiler like "Private Abstract" methods?

The reason for this is Private methods can not be overriden. So, essentially the Abstract is useless if the method is Private.

How can I create a "Private" method that's able to be overriden?

Simple, you just declare the method as "Protected Abstract". Protected defines that the method is only accessible from within the class that declared it, and from within any derived class.

Currently rated 2.3 by 3 people

  • Currently 2.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: General
Posted by crpietschmann on Tuesday, February 26, 2008 10:08 PM
Permalink | Comments (2) | Post RSSRSS comment feed

Related posts

Comments

Will Sullivan us

Wednesday, February 27, 2008 1:47 PM

Will Sullivan

I lol'd.

And its "protected abstract".

Whoever asked the original question must be smacked.

Chris Pietschmann us

Wednesday, February 27, 2008 3:26 PM

Chris Pietschmann

It may seem obvious to some, but I posted it because it seems that most .NET developers aren't the most familiar with the real differences between the Public, Private and Protected keywords.

Comments are closed

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2008 Chris Pietschmann