我想讀取一個特定的數據行到一個數組和另一行(行A)到它自己的數組中。我知道如何讓我的Excel文件閱讀,但我不知道如何獲得一個特定的行到一個數組....請幫我理解如何宣佈兩個動態並行陣列!如何創建從Excel文件讀取的動態並行數組? c#
//Checks if the ID Number Matches
string value = EmployeeIDTextbox.Text;
Match match = Regex.Match(value, @".*[0-9].*");
Console.WriteLine(value);
int TotalRows = xlsDs.Rows.Count;
for (int i = 0; i < TotalRows; i++)
{
DataRow row = xlsDs.Rows[i];
//Cell Name that contains ID Number
String row_Val = row["Enter Employee ID number"].ToString();
Match myMatch = Regex.Match(row_Val, EmployeeIDTextbox.Text);
//If ID Number is found
if (match.Success && myMatch.Success)
{
Console.WriteLine(EmployeeIDTextbox);
//Place Employee information in array
//Places Coloumn headers in array
使用2列出了與轉換數組後(如有必要) – PaulF
@PaulF我將如何聲明列表? – Cscience18
取決於數據類型,但列表 list1 =新列表();然後l1.Add(...);添加到列表&最後l1.ToArray()如果你需要轉換爲數組。 –
PaulF