codice:
string str;
while((str=scan.Substring(0,2))=="G1" || str=="G9" || str=="G2")
{
    //fa quello che deve fare
}