本文介绍了字符串构建器附加问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个POST变量DEST,如果post变量为null,那么我需要传递硬编码值app。在Redirecttopage()方法中我有字符串构建器sbSourceString。我附加sDest和userid 对此sbSourceString。我附加变量时遇到问题。请找到示例代码。

protected void Page_Load(object sender,EventArgs e)

{

string sDest = string.Empty;

if(!string.IsNullOrEmpty(Request.Form [DEST]))

{

sDest = Request.Form [DEST] ;

}

其他

{

sDest =app;

}

Redirecttopage();

}

private void Redirecttopage()

{

StringBuilder sbSourceString = new StringBuilder();

//sbSourceString.Append(\"dest=app&UserId=07-\");//早期代码



}

所以如何将我的sDest附加到字符串生成器。



请帮助指导我。



我尝试过:



在谷歌搜索。

在谷歌搜索。

在谷歌搜索。

搜索谷歌。

I have one POST variable "DEST", If post variable is null then I need to pass hardcoded value "app" .In Redirecttopage() method I have string builder "sbSourceString ".i am appending "sDest" and "userid" to this "sbSourceString ". I have issue while appending the variable. please find the sample code.
protected void Page_Load(object sender, EventArgs e)
{
string sDest = string.Empty;
if (!string.IsNullOrEmpty(Request.Form["DEST"]))
{
sDest = Request.Form["DEST"];
}
else
{
sDest = "app";
}
Redirecttopage();
}
private void Redirecttopage()
{
StringBuilder sbSourceString = new StringBuilder();
//sbSourceString.Append("dest=app&UserId=07-");//earlier code

}
so how to append my sDest to the string builder .

Please help guide me.

What I have tried:

searching in google.
searching in google.
searching in google.
searching in google.

推荐答案

sbSourceString.AppendFormat("dest={0}&UserId=07-", sDest);



这篇关于字符串构建器附加问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 11:29