public static int ClosestIntAngleFromList(float angleIn, List <int> angleList) { int item = angleList[0]; foreach (int num in angleList) { if (Mathd.AbsAngleBetween(angleIn, (float)num) >= Mathd.AbsAngleBetween(angleIn, (float)item)) { continue; } item = num; } return(item); }