Before that I wrote on D, and it's a bit complicated to understand how to do the same thing in C #.
The bottom line. I need an array of structures. The structure itself is a description of the fields in the database. Those. I want to write all the data from the database into an array of structures. How to do it right?
struct UserData { public int id; public string guid; public string name; public byte[] userblob; }; public void PGConnect() { UserData [] uds; UserData ud; // с одной структурой все работает, но мне нужен масив, я его объявил выше NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5433;User Id=" + config.PGLogin + ";" + "Password=" + config.PGPass + ";Database=" + config.PGdbName + ";"); try { conn.Open(); } catch(SocketException e) { Console.WriteLine(e.Message); } // NpgsqlCommand command = new NpgsqlCommand("SELECT city, state FROM cities", conn); string commandText = @"SELECT id, guid, username, userblob FROM ""USERS"" "; NpgsqlCommand command = new NpgsqlCommand(commandText, conn); try { NpgsqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { //ud.id = Int32.Parse(dr[0].ToString()); //ud.guid = (dr[1].ToString()); //ud.name = (dr[2].ToString()); //ud.userblob = (byte[])dr[3]; //а в массив как? } } finally { conn.Close(); } }