Hi friends,
Can we have Interface and Abstract Class without any method?
Interface and Abstract class without method?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 30, 2012, 9:25 AM EDT
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.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 30, 2012, 7:32 PM EDT
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.
Ajitender VijayRank #6,843 · 255 reputationPosted Jul 30, 2012, 8:36 PM EDT