-2
string qwe = "ABCD";

if(qwe.StartsWith("A") && qwe.EndsWith("D"))
{
    MessageBox.Show("Message");
}

What I need is to make also a decision for B and C but not StartsWith and EndsWith, it's really hard for me to explain but just like this:

if(qwe.Second("B"))
{
    //Do anything
}

and

if(qwe.Third("C"))
{
    //Do anything
}
SPQR
  • 514
  • 1
  • 7
  • 25

1 Answers1

0

You know that you can access characters via index(zero based)?

if(qwe.Length >= 2 && qwe[1] == 'B')
{
    //Do anything
}

if(qwe.Length >= 3 && qwe[2] == 'C')
{
    //Do anything
}
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939