How can i converting javascript to c#(error code CS1612)

Hi, I have to rewrite somecode. How can i covert javascript to c#. (rigidbodyObject is always moving.)

javascript here, (javascript is correct!)

function Update()
{
   rigidbody.velocity.y=Mathf.Min(rigidbody.velocity.y,0.0);
}

c# code here, (but it is not correctly working.)

void Update()
{
   rigidbody.velocity+=new Vector3(0F,(rigidbody.velocity.y,0F),0F);
}

Besides the compile issue, you're also changing the semantics of the statement

I'd change it to:

Vector3 vel = rigidbody.velocity;
vel.y = Mathf.Min(vel.y, 0);
rigidbody.velocity = vel;

That is actually how js does it in the background at any rate

rigidbody.velocity.y,0F doesn't mean anything. You forgot Mathf.Min.

rigidbody.velocity += new Vector3(0, Mathf.Min(rigidbody.velocity.y, 0));