What's wrong with my Mathf.Clamp?

I think I have found an answer to my problem. I was having the same problem as the person here: Limit local rotation - Questions & Answers - Unity Discussions

The problem is that is in JavaScript. Can someone convert it to C# and tell me how to integrate it into my script?
My script:

using UnityEngine;
using System.Collections;

public class CameraRotation : MonoBehaviour {

    float FinalRotation;
    public float GunDepression = -10.0f;
    public float GunElevation = 25.0f;
    public float XSpeed = 0.1f;
    public float YSpeed = 0.1f;
    public float Sensitivity = 100f;
    float LockPos = 0;
 


    void Update () {

        float XSpeed = Input.GetAxis ("Mouse X") * Sensitivity * Time.deltaTime;
     
        float YSpeed = Input.GetAxis ("Mouse Y") * Sensitivity * Time.deltaTime;

        transform.Rotate (YSpeed, XSpeed, 0);  //yes, those axis are correct.

        FinalRotation = transform.rotation.x;

        transform.localEulerAngles = new Vector3(Mathf.Clamp(transform.rotation.x, GunDepression, GunElevation), transform.localEulerAngles.y, LockPos);
    }
}

I think you have to convert to radians here.

This may be useful: limit rotation using math.clamp - Questions & Answers - Unity Discussions

Hey, I just updated my original post, then refreshed the page, so I then saw you’re reply. I’m not understanding that link you sent me, but it is in Javascript. In my original post I updated it with what I need. Could you help me convert whats in my original post?