csharp Search specified string inside textbox

Code Example - csharp Search specified string inside textbox

                
                        int pos = textbox1.Text.IndexOf("YYMM");
if(pos != -1)
{ 
    textbox1.SelectionStart = pos;
    textbox1.SelectionLength = 4;
    // MessageBox("Error");
}