Filtering data Input string was not in a correct format
<p>I have write e code to sort a csv file. what I need now is  to read just rows with ordered value and write them to datagridview.For example read just rows where value of Age is 22. the file looks like:</p>

<pre><code> ID Name Surname Age Salary
 1  John Asben   33  1000
 2  Adam Smith   22  1200
 3  Amanda J     22  2000
 4  George Villis 36  2300
</code></pre>

<p>My problem is in filtering data, for example when I click button show Employee by age and for type 22 for Age the program has to show in datagreedview just records ( rows) where value for column age is 22. I tried a code but it shows the error: <strong>Input string was not in a correct format.</strong> ( I think because the first row data type is different from other rows). My code looks like:</p>

<pre><code> private void btnAge_Click(object sender, EventArgs e)
    {
        List&lt;string[]&gt; parsedData = ReadAndSelectdata(@"C:\sorteddata.csv", ',');

        int age;

        if (txtage.Text != "")
        {
            age = int.Parse(txtage.Text);
            DrawDataGridView(parsedData.Where(p =&gt; (p[3] == "Age") || (int.Parse(p[3]) == age)).ToList());
        }
        else
            MessageBox.Show("Please type the age for Employee");
    }
</code></pre>
