コード例 #1
0
 public Export()
 {
     InitializeComponent();
     using (StreamReader sr = File.OpenText("data/Motorbikes.json"))
     {
         string json = sr.ReadToEnd();
         motorbikes = JsonConvert.DeserializeObject <Motorbikes>(json);// TU SABE KLK
     }
 }
コード例 #2
0
 public int id;//THIS STORES THE ID FROM FORM1
 public modifyMotorbike()
 {
     InitializeComponent();
     using (StreamReader sr = File.OpenText("data/Motorbikes.json"))
     {
         string json = sr.ReadToEnd();
         motorbikes = JsonConvert.DeserializeObject <Motorbikes>(json);//READ THE DATA FROM THE JSON AND SAVE IT IN THE motorbikes OBJECT
     }
 }
コード例 #3
0
 public void update()
 {
     listBox1.Items.Clear();                                            //Delete objects in listbox
     using (StreamReader sr = File.OpenText("data/Motorbikes.json"))    //Read JSON and stores data is sr
     {
         string json = sr.ReadToEnd();                                  //The data is the JSON is converted in a string
         motorbikes = JsonConvert.DeserializeObject <Motorbikes>(json); //We convert the string into a MMOTORBIKES object
         foreach (Motorbike bike in motorbikes.motorbikes)              //We add the motorbikes on the array into the listbox
         //El array y el objeto motorbikes se llaman igual, sorry
         {
             listBox1.Items.Add(bike.name);//In the listbox we add the names of each motorbike
         }
     }
 }