Implements and interface in c#....pls help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone pls give some comments about the following codes of interface and implements ?
2 files, ITrans.cs and DDDBIQ.cs (is part of the whole solution)

In file ITrans.cs,
namespace Trans
{
public interface ITrans
{
string DoTrans(string strXML);
}
}


In file DDDBIQ.cs,
using CDBUtil;
namespace Trans
{
public class DDDBIQ : ITrans
{
static string DoTrans(string strXML)
{
Log.WriteLine(strXML, "DoTrans");
return "<XML><ValidCode>Axis</ValidCode><STATUS>00</STATUS></XML>";
}
}
}

When I build the solution, I have the following error.

C:\Inetpub\wwwroot\CDBWebService\Trans\DDDBIQ.cs(5): 'Trans.DDDBIQ' does not implement interface member 'Trans.ITrans.DoTrans(string)'. 'Trans.DDDBIQ.DoTrans(string)' is either static, not public, or has the wrong return type.


How to reslove this? Thanks.
 
Hi
This is because you are implementing the interface function as static which
is not allowed. What happen is that the compiler expect you are creating a
new function and that you didn't implement the function of the interface ,
so it tells you that you need to do so . If you explicitly specify that
you mean the interface function by saying
static string ITrans.DoTrans(string strXML)
then it will tell you the real reason behind the error you are encountering
( the modifier static is not valid for this item). Hope that help.
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top