SHARE
TWEET

Untitled

MartinJanevski Mar 28th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace AllocateAssignment
  10. {
  11.     public class Program
  12.     {
  13.         public static void Main(string[] args)
  14.         {
  15.             var animalList = new AnimalsList();
  16.  
  17.             using (StreamReader r = new StreamReader("data/animals.json"))
  18.             {
  19.                 string data = r.ReadToEnd();
  20.                 animalList = JsonConvert.DeserializeObject<AnimalsList>(data);
  21.             }
  22.  
  23.             foreach (var animal in animalList.Animals)
  24.             {
  25.                 var oldMacdonaldLyrics = $@"
  26.                Old MACDONALD had a farm
  27.                E-I-E-I-O
  28.                And on his farm he had a {animal.Name}
  29.                E-I-E-I-O
  30.                With a {animal.Sound} {animal.Sound} here
  31.                And a {animal.Sound} {animal.Sound} there
  32.                Here a {animal.Sound}, there a {animal.Sound}
  33.                Everywhere a {animal.Sound} {animal.Sound}
  34.                Old MacDonald had a farm
  35.                E-I-E-I-O";
  36.  
  37.                 Console.WriteLine(oldMacdonaldLyrics);
  38.             }
  39.             Console.ReadLine();
  40.         }
  41.     }
  42.  
  43.     public class Animal
  44.     {
  45.         public string Name;
  46.         public string Sound;
  47.     }
  48.  
  49.     public class AnimalsList
  50.     {
  51.         private List<Animal> animals;
  52.  
  53.         public List<Animal> Animals { get; set; }
  54.     }
  55. }
  56. .
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top