Returning position of game object in c#

I need to return the x position of a game object in c#, in an if statement.
Basically, if object position x = something, then do something.
How would I go about this.
I have tried the manual, couldn’t make sense of it.
I am a javascript person.
Thanks,
Hugh

um ok no sure what you want, but I will make something up.

if( object.position.x > transform.position.x )
{
    Debug.Log("object is to the right of this " + transform.name);
}

Assuming positive x axis is pointing to the right of the screen.

It’s the same as in JS:

  if (someObject.transform.position.x == someX){
    // do something
  }

But this is a bad idea in JS, C# or Boo: x is a float, which has limited precision (about 6 or 7 digits), and hardly will be equal to another float (unless both are whole numbers). Whenever possible, use >= or <=. If this is incompatible with your logic, try Mathf.Approximately, like this:

  if (Mathf.Approximately(someObject.transform.position.x, someX)){
    // do something
  }