Inheriting Multiple interface having same name in both interface [Resolved]

Posted by Santosh86 under C# on 6/17/2016 | Points: 10 | Views : 428 | Status : [Member] | Replies : 1
1. Take 2 labels in .aspx page
2. Use following code in .aspx.cs pafe

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Inheritance : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Vehical obj = new Vehical();
lblCar.Text = ((car)obj).Drive();
lblBus.Text = ((bus)obj).Drive();

}
interface car
{
string Drive();
}
interface bus
{
string Drive();
}
class Vehical:car,bus
{
string car.Drive()
{
return "I am in CAR";
}
string bus.Drive()
{
return "I am in BUS";
}
}
}





Responses

Posted by: Sheonarayan on: 6/17/2016 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
You will need to use Explicit interface implementation, this is nothing but prefixing the namespace before interface.

Read these posts

http://www.dotnetfunda.com/articles/show/3066/explicit-interface-implementation
http://www.dotnetfunda.com/articles/show/2976/interface-explicit-interface-implementations-in-csharp

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

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

Login to post response