checking for paticular value

  • Thread starter Thread starter Vikas Kumar
  • Start date Start date
V

Vikas Kumar

i have string of first 5 numbers not necessary of length 5
eg: "1235" or "3421" or "12345"
now i want to check wether 3 is present in string or not
or 5 is present in given string or not
how can i do that
 
Vikas said:
now i want to check wether 3 is present in string or not
or 5 is present in given string or not

string myString = "54321";

if (myString.IndexOf("3") != -1) {
// 3 was in the string
}
else {
// 3 was not in the string
}

Just change the above to suit.
 
thanks
Dylan Parry said:
string myString = "54321";

if (myString.IndexOf("3") != -1) {
// 3 was in the string
}
else {
// 3 was not in the string
}

Just change the above to suit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top