3
Answers

params string[] not taking first argument

Brandon Lewis

Brandon Lewis

16y
4.5k
1
I have a method definition like this:

public void Log(Exception ex, ExceptionLevel exceptionLevel, params string[] optionalInfo)
{
   //Log the exception and such here.
}


And then if I make a method call to this method, like such:

Log(new Exception("This is a test message"), ExceptionLevel.Low, "Testing", "Exception Handling", "Operation");

The method will not get passed the very first argument, "Testing", that is passed to it and I end up with an array comprised of "Exception Handling" and "Operation", no first argument.

Has anyone else run into this issue?
Answers (3)