How to lock the cursor to the center of the screen

My code so far:

void Start ()
{
    Cursor.lockstate = lockmode.lock ;
    cursor.visible = true;
}

I used this and it worked perfectly

Cursor.lockstate = CursorLockMode.Locked;

This should lock your cursor, make sure to put it in the Start method.

If you get the error CS0117 then just capitalise the lockState.