How can I change this java to C#

var GameObject TargetA;
var GameObject TargetB;

var float speed = 0.1f;



function FixedUpdate  () {

    var weigt = Mathf.Cos (Time.time * speed * 2 * Mathf.PI) * 0.5 + 0.5;
	transform.position = TargetA.transform.position * weigt + TargetB.transform.position * (1 - weigt);

}

}

Hello.

	public GameObject TargetA;
	public GameObject TargetB;
	public float speed = .1F;

	protected virtual void	FixedUpdate()
	{
		var	weight = Mathf.Cos(Time.time * speed * 2F * Mathf.PI) * .5F + .5F;

		transform.position = TargetA.transform.position * weight + TargetB.transform.position * (1F - weight);
	}

You are welcome.

By the way, this is not really appropriate to come and only ask for code. This is not even a question.

The thing about Unity is that a large amount of the differences between C# and Javascript while using the Unity API are trivial. They mostly relate to calling functions and such (if, while, foreach, etc.).

public float speed = 0.1f;

void FixedUpdate  () {
	var weigt = Mathf.Cos (Time.time * speed * 2 * Mathf.PI) * 0.5 + 0.5;
	transform.position = TargetA.transform.position * weigt + TargetB.transform.position * (1 - weigt);
}

That should work as long as you have a TargetA and TargetB.