freeze rotation in code csharp

Code Example - freeze rotation in code csharp

                
                        GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeRotation;