Finding correct format? Arrays and Modulation I am fairly new to programming and I am having difficulty modulating the following code.

The program reads a file, selects certain requirements, and displays them.  I have tried to use passing arrays as arguments or functions as indicated in my textbook.  I have been using examples such as int getAges(int array[], integer). 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Project_2_practice
{
    class Program
    {
       static void Main(string[] args)
        {

            //Parsing data into memory
            string content;
            using (StreamReader reader = new StreamReader(File.Open("Data.txt", FileMode.Open)))
            {
                content = reader.ReadToEnd();
            }
            string[] rows = content.Split('\n'); //Each row is on a new line
            string[][] table = new string[rows.Length][];
            for (int i = 0; i &lt; rows.Length; table[i] = rows[i].Split(','), i++) ;



     //selecting information

            int[] districts = new int[rows.Length];
            int[] ages = new int[rows.Length];


            for (int i = 0; i &lt; rows.Length; i++)
            {
                districts[i] = int.Parse(table[i][3]);
                ages[i] = int.Parse(table[i][0]);
            } 
                //Analyzing selected information
                foreach (int district in districts.Distinct().OrderBy(x =&gt; x))
                Console.WriteLine("District {0} has {1} resident(s)", district, districts.Count(x =&gt; x == district));
                Console.WriteLine("Ages 0-18 : {0} resident(s)", ages.Count(x =&gt; x &lt; 18));
                Console.WriteLine("Ages 18-30 : {0} resident(s)", ages.Count(x =&gt; x &gt;= 18 &amp;&amp; x &lt;= 30));
                Console.WriteLine("Ages 31-45 : {0} resident(s)", ages.Count(x =&gt; x &gt;= 31 &amp;&amp; x &lt;= 45));
                Console.WriteLine("Ages 46-64 : {0} resident(s)", ages.Count(x =&gt; x &gt;= 46 &amp;&amp; x &lt;= 64));
                Console.WriteLine("Ages &gt;=65 : {0} resident(s)", ages.Count(x =&gt; x &gt;= 65));
        }
    }
}
Here's how I would do it. 

Update: I included a description of my code this time based on comments. 

First, reading a file into a variable so that each line of the file is its own element in an array is super easy with File.ReadAllLines(...). But I don't feel like using a variable for that is necessary here, so I immediately start using the array by using the Select(...) method. I'm using Select here to create an anonymous type (That's the return new { ... } part). 

var data = File.ReadAllLines(@"c:\temp\data.txt").Select (f =&gt; 
{
    var split = f.Split(',');
    return new { 
        Age = int.Parse(split[0]),
        District = split[3]
    };
});


At this point, I've got a type-safe collection of "data" that I can work with. That's important, and very useful.  For example.. 

var byDistrict = data.GroupBy (d =&gt; d.District);


In the line above, I've grouped the data by District. Grouping is, in my opinion, almost always better than using Distinct. 

The rest of the code is very similar to your original code, except my code avoids the need to have the age reports within a loop. 

foreach (var district in byDistrict)
{
    Console.WriteLine("District {0} has {1} resident(s)", district.Key, district.Count());

}

Console.WriteLine("Ages 0-18 : {0} resident(s)", data.Count(x =&gt; x.Age &lt; 18));
Console.WriteLine("Ages 18-30 : {0} resident(s)", data.Count(x =&gt; x.Age &gt;= 18 &amp;&amp; x.Age &lt;= 30));
Console.WriteLine("Ages 31-45 : {0} resident(s)", data.Count(x =&gt; x.Age &gt;= 31 &amp;&amp; x.Age &lt;= 45));
Console.WriteLine("Ages 46-64 : {0} resident(s)", data.Count(x =&gt; x.Age &gt;= 46 &amp;&amp; x.Age &lt;= 64));
Console.WriteLine("Ages &gt;=65 : {0} resident(s)", data.Count(x =&gt; x.Age &gt;= 65));