TypedDataSet: Why does .NET Framework accepts string in int datatable column?
<p>Here <a href="http://www.c-sharpcorner.com/UploadFile/rupadhyaya/TypedDataSets12032005021013AM/TypedDataSets.aspx" rel="nofollow">http://www.c-sharpcorner.com/UploadFile/rupadhyaya/TypedDataSets12032005021013AM/TypedDataSets.aspx</a> it says:
"we can specify the Data type when we create a DataColumn for a DataTable. This is to enforce the runtime Type-safety for the column so that only data of specified data type can be stored in the column. In the same way, in most of the cases we prefer to make a DataSet itself as Type-safe so as to protect it from runtime mismatch. Hence Typed DataSets generate classes that expose each object the in the DataSet in Type-safe manner. These classes inherits directly from DataSet class."</p>

<p>But this works whereas it shouldn't as I store id.ToString() and not id in typeof(int) id column ?</p>

<pre><code>using System;
using System.Data;

public class MyClass {

    public static void Main() {

        DataTable custTable = new DataTable("Customers");
        // add columns
        custTable.Columns.Add("id", typeof(int));
        custTable.Columns.Add("name", typeof(string));
        custTable.Columns.Add("address", typeof(string));

        // set PrimaryKey
        custTable.Columns[ "id" ].Unique = true;
        custTable.PrimaryKey = new DataColumn[] { custTable.Columns["id"] };

        // add ten rows
        for(int id=1; id&lt;=10; id++)
        {
            custTable.Rows.Add(
                new object[] { id.ToString(), string.Format(
                "customer{0}", id.ToString()), string.Format("address{0}", id.ToString()) });
        }

        custTable.AcceptChanges();

     foreach (DataRow row in custTable.Rows) {
      Console.WriteLine("{0} {1}",row["id"],row["name"]);
     }
        Console.ReadLine();
    } 
}
</code></pre>
