how to turn components on and off in unity through code

Code Example - how to turn components on and off in unity through code

                
                        //enable
GetComponent<Collider>().enabled = true;

//disabled
GetComponent<Collider>().disabled = false;