title: c# wildcards not matching datatable column values
body: <p>I am having an issue trying to match data table column names with a string containing a wildcard. </p>
  
  <p>I have a data table with various column names which includes a set named like follows: "PsA", "PsB", "PsC", ect.  I want to iterate through all the columns containing Ps in the title and use those titles to extract the data. </p>
  
  <p>I currently have the following code which fails to return any matches.  I have substituted a straight value in the if statement ("PsA") as a test, which works fine; however, when I use the wildcard, I get no matches.  I have also tried Regex with no luck.</p>
  
  <pre><code>    private void dfaSection_SelectedIndexChanged(object sender, EventArgs e)
      {
          string psText = null;
          string colID = "Ps*";
  
          offBox.Text = "";                       //Clear textbox if a reselection occurs
          psBox.Text = "";                        //Clear textbox if a reselection occurs
  
          info.offTitle = dfaSection.Text;       //Set textbox from variable
  
          dt = opr.findOffByTitle(info);          //Get datatable from SQL database
  
          if(dt.Rows.Count &gt; 0)
          {
               offBox.Text = dt.Rows[0][5].ToString();   //Set textbox from datatable
  
               foreach(DataColumn dc in dt.Columns)           //Loop through datatable columns
               {
                  if (dc.ColumnName.ToString() == colID) //Check that column title matches test string     - Later addition--&gt; &amp;&amp; dt.Rows[0][dc].ToString() != null)
                  {
                      psText = dt.Rows[0][dc].ToString() + "\n\n";    //Add data from matched column to string variable
                  }
               }
  
               psBox.Text = psText;           //Set textbox from variable
          }
  
      }
  </code></pre>
  
  <p>Edit: Issue fixed using <code>.Contains(colID)</code> Column names now being matched, string are now not being loaded to the <code>psText</code> variable, but I'll spend some time with that and get it working.  Thanks Skaros Ilias.</p>