E
Everton Berz
Hi,
In the follow program I would like to have the parameter "c" in method
"doSomething" as a value parameter, but it's running as a reference
parameter. Why? How can I get parameter "c" as a value (or clone,
copy)?
Current result:
value1
value2
Expected result:
value1
class Program
{
static void Main(string[] args)
{
SqlCommand sqlCommandSelect = new SqlCommand();
sqlCommandSelect.Parameters.AddWithValue("@col1",
"value1");
doSomething(sqlCommandSelect.Parameters);
foreach (SqlParameter param in
sqlCommandSelect.Parameters)
{
Console.WriteLine(param.Value);
}
Console.ReadLine();
}
private static void doSomething(SqlParameterCollection c)
{
c.AddWithValue("@col2", "value2");
//I want to use the new value only here
}
}
In the follow program I would like to have the parameter "c" in method
"doSomething" as a value parameter, but it's running as a reference
parameter. Why? How can I get parameter "c" as a value (or clone,
copy)?
Current result:
value1
value2
Expected result:
value1
class Program
{
static void Main(string[] args)
{
SqlCommand sqlCommandSelect = new SqlCommand();
sqlCommandSelect.Parameters.AddWithValue("@col1",
"value1");
doSomething(sqlCommandSelect.Parameters);
foreach (SqlParameter param in
sqlCommandSelect.Parameters)
{
Console.WriteLine(param.Value);
}
Console.ReadLine();
}
private static void doSomething(SqlParameterCollection c)
{
c.AddWithValue("@col2", "value2");
//I want to use the new value only here
}
}