Hi friends,
Can we have Interface and Abstract Class without any method?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jul 30, 2012, 1:25 PM
For example, an interface could consist of nothing but properties and an abstract class could consist of nothing but instance fields and properties.
However, an abstract class must have a constructor. If you don't include one, then the system provides, by default, a protected parameterless constructor which does nothing except call the base class's constructor. The constructor is only necessary for inheritance purposes as you can't instantiate an abstract class.
A constructor has similarities to a method though the two are usually regarded as distinct from one another.
Ajitender VijayPosted Jul 31, 2012, 12:36 AM
Jignesh TrivediPosted Jul 30, 2012, 11:32 PM
yes, you may... Agree with Vulpes..
Example
public interface IEntity
{
}
public class myTest : IEntity
{
public string GetName()
{
return "Test Name";
}
}
it is not Compulsory Interface and abstract class must have method. I think this will useful to acheive common behaviour of class.
hope this will help you.