Can we inherit an interface in an abstract class?
Answers were Sorted based on User's Feedback
Answer / arne
yes you can. The example from anwser #4 is incorrect.
using System;
public interface IDisplay
{
void Display();
}
public abstract class MyClass : IDisplay
{
public MyClas(){};
public abstract DoSomething();
public void Display() {};
}
This code compiles fine without a problem. Abstract classes can inherit from interfaces as an abstract class defines the the functionality and restrictions for subclasses.
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / manish gobade
in order to run the above code we must impliment display() method of interface abs into class ba.
| Is This Answer Correct ? | 4 Yes | 2 No |
Answer / sowmya
no we can't
using System;
interface abs
{
void display();
}
abstract class abs1:abs
{
public abstract void read();
}
class ba:abs1
{
int a;
public override void read()
{
Console.WriteLine("enter any value");
a=Convert.ToInt32(Console.ReadLine());
}
public void display()
{
Console.WriteLine(" Ur entered value:{0}",a);
}
}
class main
{
public static void Main()
{
ba b=new ba();
b.read();
b.display();
}
}
error CS0535: 'abs1' does not implement interface member
'abs.display()'
| Is This Answer Correct ? | 1 Yes | 6 No |
What is difference between C# and VB.NET?
Between windows authentication and sql server authentication, which one is trusted and which one is untrusted?
What is argument in c#?
How do destructors and garbage collection work in c#?
What is console read in c#?
Why var is used in c#?
What is asenumerable in c#?
How many parameters can a method have c#?
Explain the types of Polymorphism.
How do I convert a string to an int in c#?
What is difference between method overriding and method overloading?
How long does a loop recorder procedure take?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)