Skip to main content
 首页 » 编程设计

c#之在 C# 2005 中返回多个数据表

2024年02月23日17myhome

我在一个类(class)里有 table1 和 table2..

public DataTable sampletable (DataTable table1,DataTable table2) 
{ 
     // How to return the two table(table1 and table2) 
} 

提前谢谢

请您参考如下方法:

public DataTable[] sampletable (DataTable table1,DataTable table2)  
{  
    return new DataTable[] { table1, table2 }; 
}  

使用数组。并检索特定表:

DataTable[] dtArray = sampletable (YourFirstDt, YourSecondDt); 
 
DataTable table1 = dtArray[0]; 
DataTable table2 = dtArray[1];