How can i make a ,,If nothing happens then do this" ?

How can i write a code in c# that will get activated if nothing happens for a specific amount of time?

Simple Question with a probably simple answer that i cant find…

float timer = 0.0f;
float timeLimit = 5.0f;

if(somethingA){
    timer = 0.0f;
}else if(somethingB){
    timer  = 0.0f;
}else if(somethingC){
    timer  = 0.0f;
}else{
    timer += Time.deltaTime;
    if(timer>timeLimit){
        DoNothing();
    }
}