interface - C# double standard? -


After

I am doing the exact same thing in two classes, and the compiler in one still allows it for the best, But one another is giving me an error Why double standard? Using this same pattern, there are 15 classes, but refuse to compile the following one error saying:

'AWWAInvoicingXML.AwwaTransmissionInfo' does not implement the interface member ' AWWAInvoicingXML.IXmlSerializable.fromXML (System.Xml.xmlDocumentFragment) '. 'AWWAInvoicingXML.AwwaTransmissionInfo.fromXML' (System.Xml.XmlDocumentFragment) 'is either not a static public, or a false return type.

Here's my source code ... If I comment out the AwwtransmissionInfo class, compile the rest of the files properly, so I know that this is not one of those where the compiler first I am dying after the error and I know, I know what I am trying to do here, there are built-in things for this, but I think what I am actually doing and built for a reason Serial Left :)

  public interface IXmlSerializable {// If this interface is implemented, object XML string serial in XML (); IXmlSerializable fromXML (XmlDocumentFragment inXml); } Public class AwwtransmissionInfo: IXmlSerializable {public date time date time = date time.Now; Public idm count; Local string to XML () {new exception throw ("method or operation is not implemented."); } Public AwwtransmissionInfo fromXML (XmlDocumentFragment inXml) {new exception throw ("method or operation is not implemented."); }} Public class CEmail {public string email = ""; Local string to XML () {New system throwing. Exception ("The method or operation is not implemented."); } Public CEML XML (XMLDineFragment InXML) {throwing new system. Exception ("The method or operation is not implemented."); }}   

The problem is that the method must match the signature interface properly.

The easiest solution:

  public AwwaTransmissionInfo fromXML {XmlDocumentFragment inXml} { 

 < Code is to change> Public IXmlSerializable fromXML (XmlDocumentFragment inXml) { 

If you are unhappy with that, you can apply the interface explicitly. Add this:

  public IXmlSerializable IXmlSerializable.fromXML {XmlDocumentFragment inXml} {return this.fromXML (inXml); }  

Then you will have two definitions for XML, for a use when class is being called as an example, and for use on call through the interface .


Comments