如何定义和使用不定长度的字符串索引和长度
代码如下:
DataSet ds=new DataSet();
SqlConnection conn=new SqlConnection(connect_string);
SqlDataAdapter dadp=new SqlDataAdapter( "select "+FieldName+ " from "+TableName,conn);
dadp.Fill(ds);
String[] str ={ " "};
//DataColumnCollection ds.Tables[TableName];
int i=0;
foreach (DataRow row in ds.Tables[0].Rows)
{
str[i] = row[0].ToString();
i++;
}
return str;
提示我下标超过索引...
如何定义字符串数组
[解决办法]
string[] str = new string[ds.Tables[0].Rows.Count];