Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi return statement STRANGE?

Today while playing with a De-compiler, i Decompiled the .NET C# Char Class and there is a strange case which i don't Understand

public static bool IsDigit(char c)
{
    if (char.IsLatin1(c) || c >= 48)
    {
        return c <= 57;
    }
    return false;
    return CharUnicodeInfo.GetUnicodeCategory(c) == 8;//Is this Line Reachable if Yes How does it work !
}

i Used Telerik JustDecompile

like image 470
Rosmarine Popcorn Avatar asked Sep 07 '11 12:09

Rosmarine Popcorn


1 Answers

Think your decompiler might be dodgy... With Reflector I get:

public static bool IsDigit(char c)
{
   if (!IsLatin1(c))
   {
       return (CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.DecimalDigitNumber);
   }
   return ((c >= '0') && (c <= '9'));
}

And with ILSpy I get:

public static bool IsDigit(char c)
{
   if (char.IsLatin1(c))
   {
      return c >= '0' && c <= '9';
   }
   return CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.DecimalDigitNumber;
}
like image 124
MrKWatkins Avatar answered Sep 30 '22 22:09

MrKWatkins