Thursday, February 12, 2015

See if two types match with reflection in C#!

private string DecideIfToLogException(Exception ex)
{
   foreach (Type type in _loggerHelper.GetWhiteListedExceptionTypes())
   {
      if (type.IsAssignableFrom(ex.GetType()))
      {
         return "";

 
 

Technically, I think this will check to see if the second type may be cast to the first honestly so this is not a strict equality comparison.

No comments:

Post a Comment