error CS0266: Cannot implicitly convert type `object' to `UnityEngine.Vector3'. An explicit conversion exists (are you missing a cast?)

Hi,
I am Converting codes from javascript to C#.
Javascript code that gone conver is:

public function UpdatePreviewScreen (hashtable : Hashtable)
	{
		var posIn3D : Vector3;
		var ratio : float = 1;
		
		if(hashtable.Contains("Ball"))
		{
			BallIcon.Hide (false);
			posIn3D = hashtable["Ball"];
			posIn3D = posIn3D * ratio;
			posIn3D.x = posIn3D.x + GroundBG.transform.localPosition.x;
			posIn3D.z = posIn3D.z + GroundBG.transform.localPosition.y;
			BallIcon.transform.localPosition = new Vector3(posIn3D.x, (posIn3D.z), 0);
		}
         }

And, I converted to C# Like this:

public void UpdatePreviewScreen (Hashtable hashtable)
	{
		Vector3 posIn3D;
		float ratio = 1;
		
		if(hashtable.Contains("Ball"))
		{
			BallIcon.Hide (false);
			posIn3D = hashtable["Ball"];
			posIn3D = posIn3D * ratio;
			posIn3D.x = posIn3D.x + GroundBG.transform.localPosition.x;
			posIn3D.z = posIn3D.z + GroundBG.transform.localPosition.y;
			BallIcon.transform.localPosition = new Vector3(posIn3D.x, (posIn3D.z), 0);
		}
          }

Compiler shows an error at this line: PosIn3D = hashtable[“Ball”];

how to solve this ???

I got the answer.
If anyone having same kind of error kindly make use of it:
In C#, assigning to different data type need to cast.
So, I had just changed that line :

PosIn3D = hashtable["Ball"];

To:

PosIn3D = (Vector3) hashtable["Ball"];

Error is Solved. :slight_smile: :slight_smile: