title: Rounding up a time to the nearest hour
body: <p>ok basically I have a program that is re-writing text files and formatting them through various conditions, one of the conditions is that the date and time values in my original text file needs to be removed from its current location and moved into a new column I have created, this is done with the code below. I used a regex to find the date and time format and then remove it from its current location and store the value in a variable that I can use later...</p>
  
  <pre><code>if (line.Contains(date))
  {
      string pattern = @"(\d{2}:\d{2}:\d{2}\s?\d{2}/\d{2}/\d{4})";
      string input = line;
      string replacement = "";
      Regex rgx = new Regex(pattern);
      date1 = rgx.Match(input).ToString();
      string result = rgx.Replace(input, replacement);
      line = result;
  }
  </code></pre>
  
  <p>This new value that is returned gets both the time and date values but only as one string, so I then used a split (shown below) to get the two values separate, now split[0] is my time variable (00/00/00 format) - which I now need to round up to the nearest hour. I am really not sure how to go about this, any ideas ?      </p>
  
  <pre><code>string[] split = date1.Split(' ');                
  writer.WriteLine(split[0] + "\t" + split[1] + "\t" + line);
  </code></pre>