smoothly move an object from one vector to another (crashing unity)

I’m trying to move an object from one point to another (it’s important that the numbers increment exactly), I want the object to move there smoothly, though.
here’s the code I used, Unity crashed when I tried it:

    public float XPos = 2;
	public Vector2 playerPos = new Vector2 (2, 2);

	void Update ()
	{
		playerPos = new Vector2 (XPos, 2);
		//Mathf.Round (XPos);
		transform.position = playerPos;
		if(Input.GetKeyDown (KeyCode.A))
		{
			Move();
		}
	}
	void Move ()
	{
		float i = XPos + 1;
		while (XPos < i )
		{
			transform.Translate(Vector3.up * Time.deltaTime);
		}
	}

Unity did not crash. Your while loop at line 17 is stuck in an infinite loop. The body of the loop doesn’t change either the XPos or i variables, so the test you make never changes to false.