頭暈腦漲地研究了一天
現供大家分享
C#函數的參數返回結構數組實例:
///<summary>
///用戶信息結構
///</summary>
publicstructTUSER
{
publicstringLoginName;
publicstringLoginPass;
publicstringTrueName;
publicstringEMail;
publicintLevel;
}
///<summary>
///獲得所有注冊用戶
///</summary>
///<paramnameparamname=
publicboolGetUsers(outTUSER[]G_USERINFO)
{
USEROP
intCurRec=
intrec_count=
SqlConnectionmyConn=newSqlConnection(connectionString);
stringcmd=
SqlCommandmycmd=newSqlCommand(cmd
mycmd
SqlDataReaderadr=null;//創建數據讀取器
try
{
adr=mycmd
while(adr
{
rec_count+=
}
myConn
mycmd
try
{
adr=mycmd
f_TUSER=newUSEROP
while(adr
{
f_TUSER[CurRec]
f_TUSER[CurRec]
f_TUSER[CurRec]
f_TUSER[CurRec]
f_TUSER[CurRec]
CurRec+=
}
G_USERINFO=f_TUSER;
myConn
returntrue;
}
catch
{
myConn
f_TUSER=newUSEROP
f_TUSER[
f_TUSER[
f_TUSER[
f_TUSER[
f_TUSER[
G_USERINFO=f_TUSER;
returnfalse;
}
}
catch
{
myConn
f_TUSER=newUSEROP
f_TUSER[
f_TUSER[
f_TUSER[
f_TUSER[
f_TUSER[
G_USERINFO=f_TUSER;
returnfalse;
}
/////////////////在WEBFORM中調用如下:
privatevoidButton
{
KSBM
///為什麼不
KSBM
boolret=f_USOP
if(f_TUSER
{
for(intiloop=
{
Response
Response
Response
Response
Response
}
}
以上介紹C#函數的參數返回結構數組
From:http://tw.wingwit.com/Article/program/net/201311/11930.html