It seems your function definition does not make sense. You should try to use only the return integer, not the parameter as:
public int _countContacts()
{
int count = 0;
string query = @"select count(Contact ID) as count from Contacts";
dt = _result(query);
for (int x = 0; x < dt.Rows.Count; x++)
{
count = Convert.ToInt16(dt.Rows[x]["count"].ToString());
}
return count;
}
One other thing I noticed in your code that may be an error (or it may be correct and I don't truly understand your algorithm): In the line count = Convert.ToInt16... you are overwriting the value of count for every row in your data table. Is this wanted? Better code may be this:
for (int x = 0; x < dt.Rows.Count; x++)
{
count += Convert.ToInt16(dt.Rows[x]["count"].ToString());
}