开发者

c# compare 2 strings

I'm looking to do something in C# but just not sure of the syntax.

I return a string from a database and want to check if that string is present an开发者_JAVA技巧ywhere in a TextBox.

How do I do this?


I think I understand your question.

You can use the Contains method to test if your string is contained within the textbox value

TextBox1.Text.Contains(yourString)


Probably this is too obvious?:

if ( myTextBox.Text.Contains(myStringFromDB) )
{
    // Is contained, do something...
}
else
{
    // Is not contained, do something else...
}

For Windows Forms, see this TextBox class, for Web Forms see this TextBox class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜