找到你要的答案

Q:Check contents of a string and clear contents

Q:检查字符串的内容并清除内容

I am trying to find a way to check the contents of a string in my WindowsPhone 8.0 Silverlight app.

So far I have the following code:

if(MyURI2.Contains(App.MyPurchaseLink_URI))
{
    // TODO
}

App.MyPurchaseLink_URI is set later in the code and will contain a url which is then passed through to the following page where it is retrieved as MyURI2.

On the users second visit to this page, I would like to check the contents of App.MyPurchaseLink_URI and if it contains any data within it, I would like to clear that value and continue executing the rest of my code.

我试图找到一种方式来检查我的WindowsPhone 8 Silverlight应用程序的字符串的内容。

到目前为止,我有以下代码:

if(MyURI2.Contains(App.MyPurchaseLink_URI))
{
    // TODO
}

app.mypurchaselink_uri设置在后面的代码将包含一个URL,然后通过以下页面,它是通过myuri2。

在用户的第二次访问这个页面,我想检查app.mypurchaselink_uri内容,如果它包含任何数据在里面,我想清楚了,价值和继续执行我的代码的其余部分。

answer1: 回答1:

Tried some things out and the following seemed to work.

if(MyURI2.Contains(App.MyPurchaseLink_URI))
{
    MyURI2 = "";
}

尝试了一些东西,以下似乎工作。

if(MyURI2.Contains(App.MyPurchaseLink_URI))
{
    MyURI2 = "";
}
answer2: 回答2:

you will have to use stringbuilder class for changing the value of a string because the string class is an immutable class. Declaration is StringBuilder MyURI2="";

if(MyURI2.Contains(App.MyPurchaseLink_URI)){
MyURI2.clear();    }

now the string gets empty

you will have to use stringbuilder class for changing the value of a string because the string class is an immutable class. Declaration is StringBuilder MyURI2="";

if(MyURI2.Contains(App.MyPurchaseLink_URI)){
MyURI2.clear();    }

现在字符串空了

c#  if-statement  windows-phone-8