kumar k

kumar k

  • NA
  • 26
  • 23.6k

Can an abstract class have non-abstract methods without implementation?

Apr 27 2011 1:16 PM
Hi ,

Can some one please share their thoughts on this  Abstract class ?

 using System.ComponentModel;
 public abstract class BaseClass:INotifyPropertyChanged
  {
  protected BaseClass(); 
  protected void OnPropertyChahnged();
  public event PropertyChangedEventHandler PropertyChanged;
  }

The above code is not compiling as it  is looking for method implementations , as non-abstract methods must have body {}.
When i make protected BaseClass(); as Protected BaseClass(){}; bulid succeeds. similarly with OnPropertyChanged() method.

Please consider that the methods were not declared as abstract. Without declaring the methods as abstract those methods have empty implementation.(This is  what i'm looking to achieve).

I am referring to the above code from .Net 2.0 already existing in one of my proj , just wondering if c#2.0 has some flexibility which allows empty method implementations?

Appreciate your time

cheers,
kumar

Answers (12)