You can select each one separately using Delegate.GetInvocationList().
foreach (Render render in ToRender.GetInvocationList())
{
...
}
Note that it GetInvocationList()simply returns Delegate[], but foreachhas an implicit cast to each element, which makes the work of this loop higher.
, , ToRender null , - NullReferenceException. , , , #: (
, :
public static IEnumerable<T> GetIndividualDelegates<T>(this T multiDelegate)
where T : class
{
if (multiDelegate == null)
{
yield break;
}
Delegate d = (Delegate)(object) multiDelegate;
foreach (Delegate item in d.GetInvocationList())
{
yield return (T)(object) item;
}
}
( - .)
, :
foreach (Render render in ToRender.GetIndividualDelegates())
{
...
}
, ToRender .