Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 27th, 2012  |  syntax: C#  |  size: 1.58 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. public class Earthquake
  9. {
  10.   public double Magnitude { get; set; }
  11.   public string Location { get; set; }
  12.   public string Latitude { get; set; }
  13.   public string Longitude { get; set; }
  14.   public double depth { get; set; }
  15.   public DateTime date { get; set; }
  16.   public string EventID { get; set; }
  17.   public string URL { get; set; }
  18.   public Earthquake()
  19.     : this(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty)
  20.   { }
  21.  
  22.   public Earthquake(string magna, string locate, string lat, string longi, string dept, string dat, string Event, string website)
  23.   {
  24.     Magnitude = Convert.ToDouble(magna);
  25.     Location = locate;
  26.     Latitude = lat;
  27.     Longitude = longi;
  28.     depth = Convert.ToDouble(dept);
  29.     date = Convert.ToDateTime(dat);
  30.     EventID = Event;
  31.     URL = website;
  32.   }
  33.  
  34. }
  35.  
  36. public class ManageData
  37. {
  38.   public void getData()
  39.   {
  40.     var Quakes = new List<Earthquake>();
  41.  
  42.     string[] text = File.ReadAllLines(@"Earthquakes.csv");
  43.     foreach (string line in text)
  44.     {
  45.       string[] myColumns = line.Split(',');
  46.       Earthquake earth = new Earthquake(myColumns[0], myColumns[1], myColumns[2], myColumns[3], myColumns[4], myColumns[5], myColumns[6], myColumns[7]);
  47.       //here i want to put each data in the Earthquake class
  48.       Quakes.Add(earth);
  49.     }
  50.  
  51.     //Now for the sorting bit
  52.     var QuakesSortedByDepth = Quakes.OrderBy(q => q.depth);
  53.   }
  54.  
  55.  
  56. }
clone this paste RAW Paste Data