ArgumentOutOfRangeException – How to add InnerException

Code:

switch (Category)
{
   case Category.Id:
    var test = string.Empty;
    break;
   default:
    throw new ArgumentOutOfRangeException("Invalid category", InnerException);
}

How to implement InnerException in the second argument

>Solution :

Declare Exception and use it

throw new ArgumentOutOfRangeException("Invalid category", ex.Message);

Leave a Reply