Ray.direction editing not working in C#?

Hello,

So today I decided to transfer my FPS code from UnityScript to C#,
and I only have one more problem. this piece of code:

    void  ShootReg (){
        Transform trf = transform; // a little optimization
        RaycastHit hit;
        Quaternion hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
        Transform cam = Camera.main.transform;
        Ray ray = new Ray(cam.position, cam.forward);

    
        ray.direction.x += Random.Range(-CurrentSpreadF, CurrentSpreadF);
        ray.direction.y += Random.Range(-CurrentSpreadF, CurrentSpreadF);
        ray.direction.z += Random.Range(-CurrentSpreadF, CurrentSpreadF);
 
        if(Physics.Raycast (ray, out hit, Distance)){

causes this error:
“Cannot modify a value type return of ‘UnityEngine.Ray.Direction’. Consider storing the value in a temporary variable.”

Any help?

Something like this has always solved the issue for me:

Vector3 v3T = ray.direction;
v3T.y += Random.Range(-CurrentSpreadF, CurrentSpreadF);
v3T.y += Random.Range(-CurrentSpreadF, CurrentSpreadF);
v3T.z += Random.Range(-CurrentSpreadF, CurrentSpreadF);
ray.direction = v3T;