Hi,
I have been trying to declare an array of generic type, that I want pass as an argument of a function . I have a generic class with two properties;
I am trying to take an array of this class as an argument of a function, in some other class - something like this:
Buth this throws error. Could any Guru help?!?
I have been trying to declare an array of generic type, that I want pass as an argument of a function . I have a generic class with two properties;
Code:
public class ColumnValuePair<TKey>
{
public string mstrColumn;
public TKey mValue;
}
Code:
public Int32 GetIdentity(argTable, params ColumnValuePair<>[] argKey)
{
StringBuilder sql = new StringBuilder();
sql.Append("SELECT " + this.Column + " FROM " + this.Table + " ");
sql.Append("WHERE ");
foreach (ColumnValuePair<int, int> key in argKey)
{
sql.Append(key.Column + " = ");
if (key.Value is string)
{
sql.Append("'" + key.Value + "'");
}
else
{
sql.Append(key.Value);
}
sql.Append(" AND ");
}
if (argKey.Length > 0)
{
sql.Remove(sql.Length - 5, 5);
}
Int32 id = (Int32)SqlHelper.ExecuteScalar(this.Connection, System.Data.CommandType.Text, sql.ToString());
return id;
}
Comment