title: How do I merge two columns in a DataSet?
body: <p>Previously I've asked about <a href="https://stackoverflow.com/questions/351557/how-does-one-insert-a-column-into-a-dataset-between-two-existing-columns">inserting a column into a dataset</a>. I now have a similar question...namely merging two or more columns into a single column.</p>
  
  <p>Lets say I have the following data set:</p>
  
  <pre><code>DataSet ds = new DataSet();
  ds.Tables.Add(new DataTable());
  ds.Tables[0].Columns.Add("id", typeof(int));
  ds.Tables[0].Columns.Add("firstname", typeof(string));
  ds.Tables[0].Columns.Add("lastname", typeof(string));
  </code></pre>
  
  <p>I am needing to combine the "firstname" and "lastname" columns into a single column called "name".</p>
  
  <p>Would it be best for me to create a method that merges two columns together or a more general one that can be used to merge multiple columns together?</p>
  
  <p>My idea is to create a generalized method sort of like the following:</p>
  
  <p>MergeColumns(string format, string mergedColumn, DataTable dt, params string[] columnsToMerge)</p>
  
  <p>The user supplies a format as follows: "{0} {1}"</p>
  
  <p>mergedColumn is the name of the new column...but it must be able to be the same as one of the columns that will be merged cause in my real world case I'm merging "name" and "given_names" into "name"...but I still want to be able to use it if I ever needed to merge "street", "city", "state" "postcode" etc into a column called "address".</p>
  
  <p>The way I am thinking this would be used is as follows:</p>
  
  <p>MergeColumns("{0} {1}", "name", dataTable, "firstname", "lastname");</p>
  
  <p>given the above dataset, I would expect the resultant data set to look as follows:</p>
  
  <pre><code>DataSet ds = new DataSet();
  ds.Tables.Add(new DataTable());
  ds.Tables[0].Columns.Add("id", typeof(int));
  ds.Tables[0].Columns.Add("name", typeof(string));
  </code></pre>
  
  <p>Does this seem like a reasonable approach? Does a method like this already exist? I don't want to reinvent the wheel. Also, am I creating a method that does more than I actually need right now?</p>