FileAssociation/ProgramAssociationInfo.cs
/// <summary>
/// Attempts to convert the value within the input byte array into an integer.
/// </summary>
/// <param name="arr">Byte array containing number.</param>
/// <param name="val">Converted integer if successful.</param>
/// <returns>True on success, false on failure.</returns>
Attempts to convert the value within the input byte array into an integer.
Attempts to convert the value within the input byte array into an integer .
bool TryGetInt(byte[] arr, out int val)
      {
         try
         {
            if (arr.Length == 0)
            {
               val = -1;
               return false;
            }
            else if (arr.Length == 1)
            {
               val = arr[0];
            }
            else
            {
               val = BitConverter.ToInt32(arr, 0);
            }
            return true;
         }
         catch
         {
         }
         val = 0;
         return false;
      }
bool TryGetInt ( byte [ ] arr , out int val ) { try { if ( arr . Length == 0 ) { val = - 1 ; return false ; } else if ( arr . Length == 1 ) { val = arr [ 0 ] ; } else { val = BitConverter . ToInt32 ( arr , 0 ) ; } return true ; } catch { } val = 0 ; return false ; }
Attempts to convert the value within the input byte array into an integer.
Attempts to convert the value within the input byte array into an integer .
True on success, false on failure.
True on success false on failure .
arr
byte[]
Byte array containing number.
Byte array containing number .
int
out
val
Converted integer if successful.
Converted integer if successful .