I have a Textbox. When i will put any string in textbox, i need to check with below strings. These below strings will come from Database: string stringList = "\\"" + string.Join("\\",\\"", fetchedString) + "\\"";
Output Example: "ABCD1234","EFGH5678","IJKL9101" (These are not fixed strings). Please help me how will TextBox.Text string will be checked or compared with string list?
It's unclear what you're trying to achieve? Please post an example of some code or what you have tried already.
As it stands, you can get the contents of the text box as a string with the following
TextBox.Text.ToString()
And you should split up stringList into seperate strings using String.Split so that you can iterate through them to compare against your TextBox.
Try this might help you
bool isContain;
foreach (var item in stringList)
{
if (TextBox.Text == item.ToString())
{
isContain = true;
break; //using break depend on your requirement
}
else
{
//Not contain
}
}
您可以将字符串存储在列表中,然后使用Linq来检查它们是否已经存在。
var match = listOfStrings.Any(i => i.Equals(Textbox.Text))) ? "Matched" : "Not Matched";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.