Check if a deligate/event has a particular function

if there a way to check if a delegate/event has a particular function attached to it

for an example in rough code

delegate onClickDeligate
delegate onClickDeligate2

if(count > 2)
{
 onClickDelegate += function;
}
else
{
 onClickDelegate2 += function;
}

void function
{
 // here i need to check both delegates and remove it based on what one is attached to it
// if i try to just remove both it crashed when i do (-= delegate) for one that is not attached to it
}

is there a way of checking a delegate and removing it if there is? sorry if the example is written terrible.

You can try checking the delegate to null if it is not allocated it will return null, so no need to remove the handler.

if(onClickDelegate != null)
{
   onClickDelegate -= function;
}

To make sure you have registered a function you can look at the invocation list of delegate. See this and this.

Also, have a look at this example to begin.