[C#] How to get the Object calling a custom method in a custom class

Hello everyone!

Here i have a simple class method that takes 2 inputs, one is a custom gameobject and the other is that custom gameobject’s X Y or Z axis.
to call it you must do something like this.

Instance.LocalPosition(this.gameObject,"x");

as you can see i named the method “LocalPosition” because thats what i want… this is to find the X,Y or Z axis of the object that is calling the method, how would i get rid of the “this.gameObject” parameter??

Thanks in advance!
Dmaj

Also this is the Methods script

	public static int LocalPosition(GameObject GAMEOBJECT,string PLANE)
	{
		if(PLANE == "X" || PLANE == "x")
		{
			return (int)(GAMEOBJECT.transform.position.x);
		}
		else if(PLANE == "Y" || PLANE == "y")
		{
			return (int)(GAMEOBJECT.transform.position.y);
		}
		else if(PLANE == "Z" || PLANE == "z")
		{
			return (int)(GAMEOBJECT.transform.position.z+1);
		}
		else
		{
			return -1;
		}
	}

The function is static, which means it does not have an instance to work with. This is more what you want.

public int LocalPosition(string PLANE) {
        if(PLANE == "X" || PLANE == "x")  {
            return (int)(transform.position.x);
        }
        else if(PLANE == "Y" || PLANE == "y") {
            return (int)(transform.position.y);
        }
        else if(PLANE == "Z" || PLANE == "z") {
            return (int)(transform.position.z+1);
        }
        else {
            return -1;
        }
    }

But at this point you might as well just use

instance.gameObject.transform.position.x;