.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> OOPS >> Post New QuestionBookmark and Share Subscribe to Forum

OOPs

Posted By: Nagaraju     Posted Date: June 09, 2011    Points:5   Category :OOPS
I am having two interfaceses. Two interfacess having same Sub method
signature with method name. i am going to implement in another class?
What is the result?


Public Interface Intef1

Sub ABC(ByVal id As Integer, ByVal location As Integer)

End Interface

Public Interface Intef2
Sub ABC(ByVal id As Integer, ByVal location As Integer)
End Interface

I am going to implement in a class with these two intefacess
what is the outpur?

Public Class IntefTest
Implements Intef2, Intef1, Interf3
Public Sub ABC(ByVal id As Integer, ByVal location As Integer) Implements Intef1.UHID
Dim s As String = "1"

End Sub
Public Sub ABC(ByVal id As Integer, ByVal location As Integer) Implements Intef2.UHID
Dim d As String = "2"

End SuB

---------------------------- IN ASPX PAGE--------------------
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim d As New IntefTest
d.UHID(10, 10101)
Label1.Text = "Intef1"
'ClientScript.RegisterStartupScript(Me.GetType, "Naga", "Javascript:Alert(Interface1)", True)
d.UHID(20, 10102)
Label1.Text = "Intef2"
'ClientScript.RegisterStartupScript(Me.GetType, "Naga", "Javascript:Alert(Interface2)", True)


End Sub


Responses
Author: SureshM             
Posted Date: June 10, 2011     Points: 20   

Hi Nagaraju,

When i try like this in c#, it shows an error : The call is ambiguous between the following methods TESTING.TST1() and TESTING.TST1().


I did the followings:


protected void Page_Load(object sender, EventArgs e)
{

string str="";

TESTING objtes = new TESTING();
str = objtes.TST1();
Response.Write(str );
}


public interface TEST1
{
string TST1();
}

public interface TEST2
{
string TST1();
}

public class TESTING:TEST1,TEST2
{
public string TST1()
{
return "IN1";
}

public string TST1()
{
return "IN2";
}
}

Author: Nagaraju             
Posted Date: June 10, 2011     Points: 20   

I did not get.

str = objtes.TST1();
Which interface will react at the runtime.

Here in TESTING class TST1() is two time. Compiler will trhow an error.

If you don't think, Can you provide clear answer?





Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend