Few questions about implementing interfaces

I am working on a Xamarin mobile application for Android. I am learning C# and Xamarin at the same time, coming from a Python background. I ran into an issue where, after Googling for a while, it turns out that I have to implement an interface. So I tried it. I inherited from the interface and fumbled through adding a few things at a time until errors went away.

Error-free but it wasn't working, so I went back to Google and found a github post where (it appears) someone who works for Xamarin gives an example of how to implement the interface — and a TON of stuff happens inside the methods that he implements. I went back through the documentation and didn't find anything about what had to happen inside of the interface and my questions are:

  • If it weren't for that post/example, how would I ever know what is to be done inside of an interface?
  • How do I know what methods MUST be implemented? Is it even possible without examples?
  • When implementing an interface is there ever a time when the interface comes with code already (like inheriting a class)?

by exxy- via /r/csharp

Leave a Reply