Basic: How to get a specific character from a string?

  • Thread starter Thread starter Juan
  • Start date Start date
for(int i=0; i<s.Length; i++)
{
if (s == charVariableForCharLookingFor)
{
// grab the index or return true or whatever you need to do when you
find it.
}
}
 
also, you could do

int intPosition = s.IndexOf(charVariableForCharLookingFor)


Patrick Altman said:
for(int i=0; i<s.Length; i++)
{
if (s == charVariableForCharLookingFor)
{
// grab the index or return true or whatever you need to do when you find
it.
}
}


 

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