Last active
October 23, 2023 11:30
-
-
Save arafattehsin/4fcf231455bacd258dfeda536fd2b4eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<List<Country>> LoadCountries() | |
{ | |
try | |
{ | |
using var stream = await FileSystem.OpenAppPackageFileAsync("countries.json"); | |
using var reader = new StreamReader(stream); | |
var contents = reader.ReadToEnd(); | |
var countries = JsonSerializer.Deserialize<List<Country>>(contents); | |
return countries; | |
} | |
catch(Exception ex) | |
{ | |
throw new Exception(ex.Message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment