List Info

Thread: C-Sharp (C#) Group: Parameter as reference but I am not using "ref"




C-Sharp (C#) Group: Parameter as reference but I am not using "ref"
country flaguser name
United States
2007-10-12 11:14:49
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
	}

}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C-Sharp (C#)" group.
To post to this group, send email to C_Sharpgooglegroups.com
To unsubscribe from this group, send email to
C_Sharp-unsubscribegooglegroups.com
For more options, visit this group at http://g
roups.google.com/group/C_Sharp?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )