oop - Understanding Interfaces C# -


been reading day on interfaces , abstract classes trying grasp on them better understand amazon library i'm working with. have code:

using mwsclientcsruntime;  namespace marketplacewebserviceorders.model {     public interface imwsresponse : imwsobject     {         responseheadermetadata responseheadermetadata { get; set; }     } 

and

namespace mwsclientcsruntime {     public interface imwsobject     {         void readfragmentfrom(imwsreader r);         string toxml();         string toxmlfragment();         void writefragmentto(imwswriter w);         void writeto(imwswriter w);     } } 

my first questions thought interfaces cannot contain fields, can contain properties usch responseheadermetadata?

second, in main program have line of code:

imwsresponse response = null; 

with response being later used store information amazon sends after method call invoked. but meaning behind setting variable of interface type null?

also, interface can implement interface? isn't classes can implement interfaces, interfaces well?

pproperties can present in interfaces since properties methods - use of t getsomevalue() alongside void setsomevalue(t value) became common in other languages, c# implements these properties.

the meaning behind setting interface member null same setting anyother property null - since property's set accessor method, it's calling other method on interface. null means implementation.

interfaces not implement each other, since , interface cannot contain code , therefore not implementing; interface inheritance allows 1 require 1 interface in another. big example ienumerable<t>, closely tied ienumerable inherits, meaning class implementing ienumerable<t> must implement ienumerable.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -