title: how do i refactor these 2 methods?
body: <pre><code>    public static void outputDetail(DateTime previousTime, ref double[] array, StreamWriter streamWriter)  //the parameter in here is not necessary, but want to maintain a similiarity in the TimeOfDay class
      {
          string outputString = previousTime.ToString("yyyy/MM/dd");
          Boolean bypass = true;
  
          for (int i = 1; i &lt; array.Length - 1; i++)
          {
              outputString = outputString + "," + array[i].ToString();
  
              if (array[i] != 0)
                  bypass = false;
          }
          if (bypass == false)
              streamWriter.WriteLine(outputString);
  
          for (int i = 0; i &lt; array.Length; i++)
          {
              array[i] = 0;
          }
      }
  
  
      public static void outputDetail(DateTime previousTime, ref int[] array, StreamWriter streamWriter)  //the parameter in here is not necessary, but want to maintain a similiarity in the TimeOfDay class
      {
          string outputString = previousTime.ToString("yyyy/MM/dd");
          Boolean bypass = true;
  
          for (int i = 1; i &lt; array.Length -1; i++)
          {
              if (array[i] != 0)
              {
                  outputString = outputString + "," + array[i].ToString();
                  bypass = false;
              }
              else
              {
                  outputString = outputString + ",";
              }
          }
          if (bypass == false)
              streamWriter.WriteLine(outputString);
  
          for (int i = 0; i &lt; array.Length; i++)
          {
              array[i] = 0;
          }
      }
  </code></pre>
  
  <p>they are exactly the same, only one takes a double array and one takes an int array, i see some example use Iconvertible but i cant get the syntax right. can someone post some workable snippet for the method pls?</p>
  
  <p>can how do i call it?</p>
  
  <p>EDIT: thanks very much for the answer, i have another somewhat more complicated case i need to refactor, and the suggestion in here dont work on that 2 methods. Please click this link for more detail</p>
  
  <p><a href="https://stackoverflow.com/questions/12620374/how-do-i-refactor-these-2-method-part-2">How do I refactor these 2 methods? Part 2.</a></p>