title: how to get first element from a Tupled List
body: <p>I have a list i.e.</p>
  
  <pre><code>var d = new List&lt;Tuple&lt;string, double&gt;&gt;();
  </code></pre>
  
  <p>used in following code as under:</p>
  
  <pre><code>var d = new List&lt;Tuple&lt;string, double&gt;&gt;();
              while ((line = file.ReadLine()) != null)
              {
                  d.Add(Tuple.Create(line, p.calculate_CS(line, document)));
              }
  
  
              System.IO.StreamWriter fileW = new System.IO.StreamWriter(@"C:\Users\Malik\Desktop\write_research_fields_temp.txt");
  
              foreach (var item in d.OrderByDescending(t =&gt; t.Item2))
              {
                  fileW.WriteLine("{0} - {1}", item.Item2, item.Item1);
  
              }
  </code></pre>
  
  <p>I want to store first element (only string value not double value) of sorted (descending) List in a string i.e. <code>string top_value</code></p>
  
  <p>Any suggestion are highly appreciated.
  Thanks</p>
  
  <hr>
  
  <pre><code> var dd = new List&lt;Tuple&lt;string, double, string&gt;&gt;();
  
              while ((line = file.ReadLine()) != null)
              {
                  dd.Add(Tuple.Create(line, p.calculate_CS(line, document), document));
              }
  
              var top_value = dd.OrderByDescending(x =&gt; x.Item2).FirstOrDefault();
  
              if (top_value != null)
              { 
                  // look up record using top_value.Item3, and then store top_value.Item1
                  var abstrct = top_value.Item3.ToString();
                  var r_field = top_value.Item1.ToString();
  
                  write_To_Database(abstrct, r_field);
              }
  </code></pre>
  
  <p>This is insertion method to insert data into database.</p>
  
  <pre><code>static void write_To_Database(string document, string research_field)
          {
              try
              {
                  SqlConnection con = new SqlConnection("Data Source=KHIZER;Initial Catalog=subset_aminer;Integrated Security=True;");
  
                  con.Open();
                  SqlCommand query = con.CreateCommand();
                  query.CommandText = "select id from sub_aminer_paper where pid between 1 and 500 and DATALENGTH(p_abstract) != 0 and p_abstract = " + document;
  
                  SqlDataReader reader = query.ExecuteReader();
  
  
                  reader.Read();
                  int id = reader.GetInt32(0);
                  //reader.Close();
  
                  query.Parameters.Add("@research_field", SqlDbType.Text);
                  query.Parameters.Add("@id", SqlDbType.Int);
  
                  query.CommandText = "insert into sub_aminer_paper (research_area) values(@research_field) where id = @id";
                  query.ExecuteNonQuery();
  
  
                  con.Close();
              }
              catch (Exception e)
              {
                  Console.WriteLine("Exception: " + e.Message);
              }
              finally
              {
                  Console.WriteLine("Executing finally block.");
  
              }
          }
  </code></pre>
  
  <p>Any suggestions?</p>