Answer the question
In order to leave comments, you need to log in
What type of data to return from the function when compiling the list?
There is a function that returns a list of data received from the database, what type should it have?
public ??????????????? CreditsList(Credit.MainWindow MainWindow)
{
Connection();
string query = "SELECT * FROM credits";
SqlCommand command = new SqlCommand(query, connection);
SqlDataReader reader = command.ExecuteReader();
List<CreditsList> result = new List<CreditsList>();
while (reader.Read())
{
int credit_id = Convert.ToInt32(reader["credit_id"]);
string credit_name = Convert.ToString(reader["credit_name"]);
double credit_percent = Convert.ToDouble(reader["credit_percent"]);
string credit_info = Convert.ToString(reader["credit_info"]);
result.Add(new CreditsList(credit_id, credit_name, credit_percent, credit_info));
}
reader.Close();
connection.Close();
return result;
}
Answer the question
In order to leave comments, you need to log in
Since you return the list result , which you have List<CreditsList>
, then I dare to assume that the type of the method should also beList<CreditsList>
Yes, though object
, the topic of the question is not disclosed. Why are you not satisfied with the current type?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question