Incremental Counter

Okay. would it work if I put the code like this?

  if (digitalRead(inductiveSensorpin7)) {
    x++;
  }