How to make class abstract without using interface....

Posted by Ray.chayan under C# on 6/23/2010 | Views : 1987 | Status : [Member] | Replies : 2
Hi , we know OOPS has a feature called abstraction. How can we implement abstraction in a class without implementing any Interface ?




Responses

Posted by: Deeraj on: 6/23/2010 [Member] Starter

Up
0
Down
Mark the class as abstract.


abstract class TestAbstract
{
public abstract int add(int a, int b);
}


Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 6/23/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Abstract class and Interface are two different concepts.

Implements lets you to define a structure so that every class that follows this structure can perform certain sets of actions. Thus you can send objects like List<string> into IEnumerable<string> as List<string> implements IEnumerable<string>

Abstract class are actual partial implementation of a class. So when you want to define a few methods in your class and rest be declared by other classes deriving it, you can use abstract classes.

As Deeraj already suggested, abstract class can be created using abstract keyword.


www.abhisheksur.com

Ray.chayan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response