title: passing SqlDataReader to function as parameter for casting
body: <p>for casting data of SqlDataReader I do these (example for common data types):</p>
  
  <pre><code>string name = reader["name"].ToString();  //for string
  
  
  int i = 0; i = int.TryParse(reader["i"].ToString(), out i);       //for int
  int i = reader.GetInt32(reader.GetOrdinal("i"));                  //or this again for int
  
  bool b = reader.GetBoolean(reader.GetOrdinal("b"));               // for boolean
  </code></pre>
  
  <p>I want to create a class with these functions:</p>
  
  <pre><code>public static class gd{
     public static bool Bool(SqlDataReader rd, string name)
      {
           return rd.GetBoolean(rd.GetOrdinal(name));
      }
     public static int Int(SqlDataReader rd, string name)
      {
           int i=0;
           i = int.TryParse(reader["i"].ToString(), out i); 
           return i;
      }
  }
  </code></pre>
  
  <p>and then just use:</p>
  
  <pre><code>int i=c.Int(reader,"i");
  bool b=c.Bool(reader,"b");
  DateTime dt = c.Date(reader,"dt");
  </code></pre>
  
  <p>I want to know is it a good idea to pass datareader as parameter? anyone has got a better Idea for casting datareader data?</p>