How to turn off a light and change its intensity. Im new thanks!1

Hi i need help. I have a spotlight and im using it as a flashlight and I cant seem to turn it off when I press a button. Here is my code. Thanks!! (Also use c#)

      `		if(flashlightDead == false){
	
		if(Input.GetKeyDown("f")){
			if(lightOff == false){
				lightOff = true;
				light.intensity = flashlightOff;
			}
			if(lightOff == true){
				lightOff = false;
				light.intensity = flashlightOff;
			}
		}
	}`

try

gameobject.setActive(false);