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!");