ich habe eine Klasse und Methodedurch einen C Looping # Sammlungen
public class Datas
{
public string Name { get; set; }
public int Value { get; set; }
}
public void Funnel()
{
string commandText = "select sc.stagename, count(cs.stages_id) as StageCount from currentstage cs inner join stagesconfig sc on cs.stages_id = sc.stages_id group by cs.stages_id,sc.stagename";
string constrings = WebConfigurationManager.ConnectionStrings["Data"].ToString();
SqlConnection myConn = new SqlConnection(constrings);
SqlCommand myComm = new SqlCommand(commandText, myConn);
myConn.Open();
List<Datas> fruitinfo = new List<Datas>();
SqlDataReader reader = myComm.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
fruitinfo.Add(new Datas
{
Name = reader.GetValue(0).ToString(),
Value = Convert.ToInt32(reader.GetValue(1))
});
}
}
wie Listen Sie Schleife durch fruitinfo es in Form eines Array Array Speicher muss dies ähnlich sein form.intended die Einzelteile ersetzen in Daten Klammer mit fruitinfo geschleift Liste
Data = new Data(new object[]
{
new object[] { "Website visits", 10000 },
new object[] { "Downloads", 5000 },
new object[] { "Requested price list", 2000 },
new object[] { "Invoice sent", 1000 },
new object[] { "Finalized", 500 }
}),
Warum brauchen Sie dieses hässliche 'Objekt []' überhaupt? –