public DataSet SeeMessage1(string type,int PersonID,int pagenumber,out int totalrecords)
{
DataSet msgobj = new DataSet();
SqlDataAdapter csCommand = new SqlDataAdapter();
SqlCommand command = new SqlCommand();
csCommand.SelectCommand = command;
command.CommandText = "Msg_GetMsgByPage";
command.CommandType = CommandType.StoredProcedure;
SqlParameter [] paras  = {   new SqlParameter("@PersonID",SqlDbType.Int),
 new SqlParameter("@Type",SqlDbType.Int),
     new SqlParameter("@PageNumber",SqlDbType.Int),
                         new SqlParameter("@PageSize",SqlDbType.Int),
                         new SqlParameter("@TotalRecords",SqlDbType.Int)
  };
paras[0].Value = PersonID;
if("recnote" == type)
{
paras[1].Value = 0;
}
else if ("sendnote" == type)
{
paras[1].Value = 1;
}
else if ( "caonote" == type)
{
paras[1].Value = 2;
}
else
{
paras[1].Value = 3;
}

paras[2].Value = pagenumber;
paras[3].Value = 10;
paras[4].Direction = ParameterDirection.Output;
foreach(SqlParameter para in paras)
{
command.Parameters.Add(para);
}
csCommand.SelectCommand.Connection = conn;
csCommand.Fill(msgobj,"simpleobj");
totalrecords = Convert.ToInt32(command.Parameters["@TotalRecords"].Value.ToString(),10);
         
return msgobj;
}
int totalCount;
msgdata = (new MsgObj()).SeeMessage1("recnote",Convert.ToInt16(this.Empid),this.ucDataNavigator.CurrentPage,out totalCount);
if ((totalCount % 10) == 0)
ucDataNavigator.TotalPages = totalCount/10;  //这里用totalCount就编译通不过,提示,局部变量totalCount没有赋制.给totalCount赋初值或改用ref,结果完全正确的.
这是为什么啊?各位大哥,C#中out是这样用的呀
我用
static void Main(string[] args)
{

           int i;
pub(out i);
Console.WriteLine(i);
Console.ReadLine();
}
static void pub( out int j)
{
j=5;
}
进行测试,结果也完全正确.为什么.希望能得到高手指点.