Help in converting this(Js) to C#

Can anyone help me convert this?

   var index : int = Time.time * framesPerSecond;

    index = index % frames.Length;

    renderer.material.mainTexture = frames[index];

2nd two lines are the same. You may have to redo how frames is declared/created. First line I’m guessing javascript is auto-converting float Time.time to an int. In C#:

int index = (int)(Time.time*framesPerSecond); // drop fraction
int index = (int)(Time.time*framesPerSecond+0.5f); // round to nearest