Is it possible not to implement interface method in implementation class?

Yes, it is indeed possible to avoid implementing interface methods in the implementation class. To achieve this, you can declare the methods you don't wish to implement as abstract within the interface. By doing so, you'll need to mark the class as abstract as well. This allows you to provide the implementation of the method in a derived class of the abstract class.

Let's take an example scenario using C#:

interface ITest
 {
        void Sum();
 }


abstract class SumTest : ITest
 {
       public abstract void Sum();
 }



In this code, the SumTest don't have the implementation of the Sum() method. This approach can be useful when you require a method implementation but don't want to provide it immediately. By using the abstract modifier, you're indicating that derived classes should implement this method. This flexibility is particularly helpful when you want to delay the implementation until a more appropriate time.

abstract class Test : SumTest
 {
        public abstract override void Sum();
 }


here in Test class also we don't have implementation of Sum() method.

Comments

Popular posts from this blog

Pagination of DataGrid in WPF using MVVM

Connect SQL Server Database to WPF Application and Perform CRUD Operations

Filter DataGrid and ListView in wpf using ICollectionView