string strsql = $"select name from 表名"; DataTable dt = base.GetDataTable(strsql); string[] result = new string[dt.Rows.Count]; for (int i = 0; i < result.Length; i++) { foreach (DataColumn item in dt.Columns) { result[i] = dt.Rows[i][item].ToString(); } } return result;
or
string strsql = $"select * from 表名"; DataTable dt = base.GetDataTable(strsql); string[] result = new string[dt.Rows.Count]; for (int i = 0; i < result.Length; i++) { foreach (DataColumn item in dt.Columns) { result[i] = dt.Rows[i]["name"].ToString(); } } return result;