The dizziness has been studied for a day, and in order to return structural arrays in the parameter of the function.
Now you share and save time.
Example: /// /// User Information Structure /// Summary> Public Struct Tuser {Public String Loginname; Public String LoginPass; Public String TrueName; Public Int Level;
/// /// Get all registered users /// / summary> /// Return User Information Structure param> Public Bool GetUsers (Out Tuser [] g_userinfo) { Userop.tuser [] f_tuser; int curRec = 0; // Initialization Record counter int REC_COUNT = 0; // Computing total record number SQLConnection myconn = new sqlconnection (connectionString); string cmd = "select * from" m_table; // SQL query statement sqlcommand mycmd = new sqlcommand (cmd, myconn); mycmd.connection.open (); // open connection sqlDataReader ADR = null; // Create a data reader try {ADR = mycmd.executeReader (); while ADR.READ ()) {REC_COUNT = 1;} myconn.close (); // Close database connection mycmd.connection.open (); // Open database connection try {adr = mycmd.executeReader (); f_tuser = new Userop.tuser [REC_COUNT]; while (adr.read ()) {f_tuser [curR] .loginname = ADR ["US_LoginName"]. TOSTRING (); f_tuser [curRec] .loginpass = ADR ["US_LoginPass"]. Tostring ); F_tuser [curR] .trueename = ADR ["US_trueename"]. TOSTRING (); f_tuser [curRec] .email = ADR ["US_EMAIL"]. Tostring (); f_tus ER [curRec] .level = int32.parse (ADR ["US_LEVEL"]. TOSTRING ()); CurRec = 1;} g_userinfo = f_tuser; myconn.close (); /// Close connection return true;} catch} MyConn.close (); f_tuser = new userop.tuser [1]; f_tuser [0] .loginname = ""; f_tuser [0] .loginpass = ""; f_tuser [0] .trumename = ""; f_tuser [0] .Email = ""; f_tuser [0] .level = 0; g_userinfo = f_tuser; return false;}} catch {myconn.close (); f_tuser = new userop.tuser [1];
F_TUSER [0] .loginname = ""; f_tuser [0] .loginpass = ""; f_tuser [0] .trueename = ""; f_tuser [0] .email = ""; f_tuser [0] .level = 0; g_userinfo = f_tuser;} / invoked in Web Form as follows: private void button3_click (Object sender, system.eventargs e) {ksbm.userop.tuser [] f_tuser; // = new ksbm.userop.tuser (); / // Why not "new" a structure array? Because the passed it is what we want, just open a storage space. Ksbm.userop f_usop = new ksbm.userop (); BOOL RET = f_usop. GetUsers (out f_tuser); /// call function, acquiring structural arrays and information if (f_tuser.length! = 0) // data length is 0, indicating that there is no return data. {For (int = 0; iLoop