我有一份清单m.我想在此结尾插入一个元素List.请告诉我如何做到这一点.
public List<double> m = new List<double>();
m[0].Add(1);
m[1].Add(2);
m[2].Add(3);
Run Code Online (Sandbox Code Playgroud)
如果我将元素7添加到结尾,我想要以下输出:
1 2 3 7
Run Code Online (Sandbox Code Playgroud) 我有一种方法可以为数据库添加值以进行所有操作.
如果从数据库中选择了此选项并且此选择从数据库返回更多行,那么如何获取行并存储在数组中?
这是方法代码:
public void ExcuteProcedure(string procName, List<SqlParameter> procparams)
{
try
{
SqlConnection mycon = new SqlConnection(connectionString);
mycon.Open();
SqlCommand mycom = new SqlCommand();
mycom.Connection = mycon;
mycom.CommandText = procName;
mycom.CommandType = CommandType.StoredProcedure;
foreach (var item in procparams)
{
SqlParameter myparm = new SqlParameter();
myparm.ParameterName = item.ParameterName;
// myparm.SqlDbType = item.SqlDbType;
myparm.Value = item.Value;
mycom.Parameters.Add(myparm);
}
var n= mycom.ExecuteScalar();
mycon.Close();
}
catch (SqlException e)
{
Console.WriteLine("Error Number is : " + e.Number);
Console.WriteLine("Error Message is : " + e.Message);
}
}
Run Code Online (Sandbox Code Playgroud)