我有兩個類。我在第2課創建了一個返回的數據表。我試圖找出如何可以在1類使用這些值我需要在另一種方法通過在類1使用返回的數據表
//例的數據表值: 在2 I類有:
public Datatable Mytable()
{
DataTable table = new DataTable();
table.Columns.Add("Column1", typeof(string));
table.Columns.Add("Column2", typeof(string));
//get values for the data row here
return table;
}
在1級,我有:
public Method1 (String A, String B)
//A and B need to represent the values in the Datatable from Class 2
{ string ab = "This is first datarow " + A + " This is second datarow " + B;
}
不知道我明白了,你是否希望第1類調用第2類中的方法來檢索數據表並用它做一些事情。或者你想讓第2類創建一個數據表,然後調用第1類中的方法並將其傳入? –
嗨,是的,我希望第1類調用第2類中的方法(列出的「Mytable」方法)並使用數據行作爲值。該數據表將有一個人的姓氏和一個人的年齡。我想要class 1在列出的「Method1」中顯示此信息。非常感謝! –