首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

一个对于输出型参数的算法,求教

2011-12-24 
一个关于输出型参数的算法,求教publicpartialclassindex:System.Web.UI.Page{publicstringouttest(outstri

一个关于输出型参数的算法,求教
public   partial   class   index   :   System.Web.UI.Page
{
        public   string   outtest(out   string   xx)
        {      
                string   me   =   "1234 ";
                string   bn   =   " ";
                if   (me   !=   " ")
                {
                        xx   =   me;
                        return   xx;
                }      
                if   (bn   !=   " ")
                {
                        xx   =   bn;
                        return   xx;
                }          
        }
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                lab();          
        }
        public   void   lab()
        {
                string   intcount;
                index   app   =   new   index();
                Label2.Text   =   app.outtest(out   intcount).ToString();  
        }
}

程序很简单,就是关于调用输出参数xx,但是在if语句中是无法return的,求如何改,但是实现的功能是一样的,判断非空是肯定需要的

[解决办法]
输出类型得参数不需要调用return,楼主设计得方法有些问题。
[解决办法]
//直接返回值
public string outtest()
{
string me = "1234 ";
string bn = " ";
if (me != " ")
{
return me;
}
if (bn != " ")
{
return bn;
}
}

//调用
Label2.Text = app.outtest();


//如果一定要用out,就不要返回值
public void outtest(out string xx)
{
string me = "1234 ";
string bn = " ";
if (me != " ")
{
xx = me;
}
if (bn != " ")
{
xx = bn;
}
}

//调用
string intcount;
app.outtest(out intcount);
Label2.Text = intcount;
[解决办法]
public void outtest(out string xx)
{
string me = "1234 ";
string bn = " ";
if (me != " ")


{
xx = me;

}
if (bn != " ")
{
xx = bn;

}
}

public void lab()
{
string intcount;
index app = new index();
app.outtest(out intcount);

Label2.Text = intcount;

}


*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)

最新版本:20070212

http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
[解决办法]
在pageLoad事件中先把
response.Querystring[ "name "];
response.Querystring[ "id "];给全局变量name,id
再在public string outtest(out string xx){} 里面处理行不

热点排行