TL;DR;
This build error already shows you where and what the problem is.
'Mapviewdetail.Ibaseurl' does not contain a Definition for 'Baseurl' and no Extension method 'Baseurl' Accepting a first argument of type 'Mapviewdetail.Ibaseurl' could be found
(Translation and highlights of mine)
'Mapviewdetail.Ibaseurl' does not have a definition for 'BaseUrl'
and no method of extension called BaseUrl
accepting as first argument a MapViewDetail.IBaseUrl
was found
You’re trying on the object of type IBaseUrl
consume a method that does not exist (BaseUrl
).
Complement
I can’t say exactly what your intention is with the code that was written, it doesn’t make much sense. Let me comment it to good old jack style:
1 - You have created a class MapViewDetail
who inherits from ContentPage
:
public partial class MapViewDetail : ContentPage
2 - Within of her you created a Interface IBaseUrl
which has a method Get
that must return a string:
public interface IBaseUrl { string Get(); }
3 - Returning to the constructor of the class MapViewDetail
is that the mistake happens:
// Intancia um objeto qualquer
var urlSource = new UrlWebViewSource();
// Tenta recuperar uma instância que implementa IBaseUrl (em outras palavras,
// a única coisa que você sabe sobre essa instância é que será possível invocar o
// método Get que te retornaria uma string)
string url = DependencyService.Get<IBaseUrl>().BaseUrl();
Theoretically, DependencyService.Get<IBaseUrl>()
already returns an instance that implements the interface you declared, which shouldn’t go wrong (but I doubt very much that it works) would be DependencyService.Get<IBaseUrl>().Get();
, which is a call to the method you stated in the interface.
However, given your previous questions and the amount of conceptual problems that this small part of the code shows, I’m assuming that you still don’t know very well the language and the development environment .Net. If that’s the case, you’re starting out on a very complicated path, because this little bit of code (as well as the Xamarin
) already uses resources such as Interfaces, Dependency injection, Inheritance and Partial classes that requires you to meet some pillars of object orientation.
Only then can we help by giving objective answers. Until then, I suggest you continue consuming the content on the subject right here in Stackoverflow in Portuguese and start from simpler implementations, as the references suggested in the tag wiki c#.
I hope I’ve helped.