Adding a simple Service
Create a folder in the MvvmCrossDemo.Core project and name it as Services. Then create a new interface called IGreetingService.cs into this folder to show the greeting text:
1
namespace MvvmCrossDemo.Core.Services
2
{
3
public interface IGreetingService
4
{
5
string GetGreetingText(string name);
6
}
7
}
Copied!
Then create an implementation for this interface in the same folder, and name it as GreetingService.cs, as shown below:
1
namespace MvvmCrossDemo.Core.Services
2
{
3
public class GreetingService: IGreetingService
4
{
5
public string GetGreetingText(string name)
6
{
7
return quot;Hello World, {name}.";
8
}
9
}
10
}
Copied!
Later I will use a real REST API service to show how to get the data from an online API.
Last modified 3yr ago
Copy link