Answer: Consider the following code snippet:
Solution:
1)Put the interface name before the method name in the implementation class.
2)remove the modifier public before the method name in the implementation class.
using System;
namespace zz
{
interface i1
{
int add(int a);
}
interface i2
{
int add(int b);
}
class abc:i1,i2
{
int i1.add(int a)
{
return a*5;
}
int i2.add(int b)
{
return b*10;
} static void Main()
{
i1 p=new abc();
Console.WriteLine(p.add(5));
i2 q=new abc();
Console.WriteLine(q.add(5));
}
}
}
//output:
25
50
Asked In: Many Interviews |
Alert Moderator