to get data from excelfile "*.xlsx" into an array using c#
<p>file path is @"E:\BCFNA-orig-1.xsl"
excel file consists of 9 columns and 500 rows i want to get data from each row into an array int[] NumberOfInputs = {7,4,4,4,2,4,5,5,0}; " the values inside array are supposed to get from excel file , use it in my program and than get data from next row.</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.IO;

namespace ConsoleApplication3
{
class Program
{
    static void Main()
    {
    }  


public class SomethingSometingExcelClass
{
    public void DoSomethingWithExcel(string filePath)
    {

        List&lt;DataTable&gt; worksheets = ImportExcel(filePath);
        foreach(var item in worksheets){
            foreach (DataRow row in item.Rows)
            {
                //add to array

            }            
        }
     }
    /// &lt;summary&gt;
    /// Imports Data from Microsoft Excel File.
    /// &lt;/summary&gt;
    /// &lt;param name="FileName"&gt;Filename from which data need to import data    
    /// &lt;returns&gt;List of DataTables, based on the number of sheets&lt;/returns&gt;
    private List&lt;DataTable&gt; ImportExcel(string FileName)
    {
        List&lt;DataTable&gt; _dataTables = new List&lt;DataTable&gt;();
        string _ConnectionString = string.Empty;
        string _Extension = Path.GetExtension(FileName);
        //Checking for the extentions, if XLS connect using Jet OleDB                          

        _ConnectionString =
                "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\\BCFNA- 

            orig-1.xls;Extended    

       Properties=Excel 8.0";

        DataTable dataTable = null;

        using (OleDbConnection oleDbConnection =
            new OleDbConnection(string.Format(_ConnectionString, FileName)))
        {
            oleDbConnection.Open();
            //Getting the meta data information.
            //This DataTable will return the details of Sheets in the Excel 

             File.DataTable dbSchema =  
     oleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables_Info,  null);
            foreach (DataRow item in dbSchema.Rows)
            {
                //reading data from excel to Data Table
                using (OleDbCommand oleDbCommand = new OleDbCommand())
                {
                    oleDbCommand.Connection = oleDbConnection;
              oleDbCommand.CommandText = string.Format("SELECT * FROM   

              [B1415:J2113]", item["TABLE_NAME"].ToString());
                    using (OleDbDataAdapter oleDbDataAdapter = new 
                    OleDbDataAdapter())
                    {
                        oleDbDataAdapter.SelectCommand = oleDbCommand;
                        dataTable = new 
               DataTable(item["TABLE_NAME"].ToString());
                        oleDbDataAdapter.Fill(dataTable);
                        _dataTables.Add(dataTable);
                    }
                }
            }
        }
        return _dataTables;
    }
       }
         }
          }

     //////////////////////////////////////
           above is the code which i am using to get data from excel but                       

      ///////////////////////////////////////////////////////


      below is the nested loop in which i want to use data
      /////////////////////////////////////////////////
        for (ChromosomeID = 0; ChromosomeID &lt; PopulationSize; ChromosomeID++)
                {
                    Fitness = 0;
                    Altemp = (int[])AlPopulation[ChromosomeID];
                    for (int z = 0; z &lt; 500; z++)
                    {
                        int[] NumberOfInputs = new int[9]; 
            //// this is the array where in which data need to be added

               InputBinary.AddRange(DecBin.Conversion2(NumberOfInputs));

                        for (i = 0; i &lt; Altemp.Length; i++)
                        {
                            AlGenotype[i] = (int)Altemp[i];
                        }
                        Class1 ClsMn = new Class1();
                        AlActiveGenes = ClsMn.ListofActiveNodes(AlGenotype);

                        ClsNetworkProcess ClsNWProcess = new 
                     ClsNetworkProcess();
                        AlOutputs = ClsNWProcess.NetWorkProcess(InputBinary, 

                      AlGenotype, AlActiveGenes);
                        int value = 0;
                        for (i = 0; i &lt; AlOutputs.Count; ++i)
                        {
                            value ^= (int)AlOutputs[i];        // xor the 
                       output of the system
                        }

                        temp = Desired_Output[0];
                        if (value == temp) // compare system Output with  
                    DesiredOutput bit by bit
                            Fitness++;
                        else
                            Fitness = Fitness;
                    }
                    AlFitness.Add(Fitness);
                }
            }
</code></pre>