massiv[i] = array{
name => "",
size => "",
position => "",
text => ""
}
У меня в проекте из бд вытаскиваются данные о объекте
public class SomeClassName {
public string Name {get;set;}
public int Size {get;set;}
public int Position {get;set;}
public string Text {get;set;}
}
List<SomeClassName> yourArray = new List<SomeClassName>();
yourArray.Add(new SomeClassName {
Name = "abc",
Size = 123,
Position = 123,
Text = "abc"
});
public class Sample
{
public int Id { get; set; }
public string Name { get; set; }
}
public List<Sample> GetSamples()
{
var result = new List<Sample>();
using (var connection = new SqlConnection("connection_string"))
{
var command = connection.CreateCommand();
command.CommandText = "SELECT id, name FROM .....";
connection.Open();
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
result.Add(new Sample
{
Id = reader.GetInt32(0),
Name = reader.GetString(1)
});
}
reader.Close();
}
connection.Close();
}
return result;
}