I am taking a web service written in VB and rewriting it in C#.
The service class implements two interfaces that have four methods each.
Three of the four methods have the same signatures method name and parameter list. The 4th method has the same name, but a different parameter list.
In VB, you explicitly identify the interface methods associated with the public service class methods. So for the methods that are the same, implementation looks like this:
class WebServiceClass
{
Public Function Method1(result as Int32) As String Implements Interface1.Method1, Interface2.Method1
Public Sub Method2(Id as Int64, P3 as Int32) Implements Interface1.Method2
Public Sub Method3(In as Int64) Implements Interface2.Method2
}
Unfortunately there is simply no direct equivalent to this VB.NET feature in C#. There is no way in C# to implement an interface method and give it a different name. This can be simulated though by just creating the name you want and having the interface implementation forward to that method name
class WebServiceClass : Interface1, Interface2
{
public string Method1(int result) { ... }
public void Method2(long id, int p3) { ... }
public void Method3(long in) { ... }
string Interface1.Method1(int result) { return Method1(result); }
void Interface1.Method2(long id, int p3) { Method2(id, p3); }
string Interface2.Method1(int result) { return Method1(result); }
void Interface2.Method2(long in) { Method3(in); }
}