Hello, good afternoon, my friends, I have a problem that I have with the whole day.
I have a class called data type that contains a string Name and a list type float Total.
public class datos
{
public string Nombre { get; set; }
public List<float> Total{get;set;}
}
Now I have a Webmethod that is called by Ajax and I return a list of data type
My method is
//datoPorSemana es una lista Global
static IList datoPorSemana = new List<datos>();
[WebMethod]
public static IList busca(List<string> pData)
{
datoPorSemana.Clear();
datoPorSemana.Add(new datos
{
Nombre= "Nombre ",
Total.Add(3),
Total.Add(5),
Total.Add(1),
});
return datoPorSemana;
}
Now my problem is this my Total variable of the class data is not of a fixed size as I can put a data I can put n data, how do I do it ??? I would like my WebMethod to be as follows
static IList datoPorSemana = new List<datos>();
[WebMethod]
public static IList busca(List<string> pData)
{
datoPorSemana.Clear();
list<float> aux = new list<float>();
for (int i = 1; i < 6; i++)
{
aux.Add(i)
}
datoPorSemana.Add(new datos
{
Nombre= "Nombre ",
Total.Add(new List<float>(aux)),
});
return datoPorSemana;
}
Or if they have any other way to fill a float array in a list it is also received, but it is important that my Total variable is a float array
Greetings.