Hi Jason,
It's probably not a two-dimensional array that you need but an IDictionary
implementation instead. Anyway, object[,] can be used to declare a two
dimensional jagged array, however, you'll probably want a type-safe solution
regardless. You could use a generic Dictionary in the 2.0 framework
instead, or better yet, create a custom KeyedCollection implementation if
the "string" is actually supposed to represent the name of the SqlParameter
to which it's associated:
class KeyedSqlParameterCollection
: KeyedCollection<string, SqlParameter>
{
public KeyedSqlParameterCollection() { }
protected override string GetKeyForItem(SqlParameter parameter)
{
return parameter.ParameterName;
}
}
KeyedSqlParameterCollection parameters =
new KeyedSqlParameterCollection();
parameters.Add(new SqlParameter("name", "value"));
SqlParameter sqlParam = parameters["name"];
Debug.Assert((string) sqlParam.Value == "value", "Uh oh!");
--
Dave Sexton
http://davesexton.com/blog
"Jason Huang" <Ja************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,
In my C# windows form MyForm, I would like to have an array which is
[string, SqlParameter]
How do I declare this kind of array in C#?
Thanks for help.
Jason