There might be similar questions already, but I think I have a specific case here
I'm trying to understand how an existing application is working and debugging it right now
It is a console application where I'm providing 6 parameters:
- JobName
- Boolean flag
- File location
- FileType
- Date
- FileAppID
I provide the list of parameters through the Command line arguments value under "Debug" section of the project
So, it look something like that: "MyJobName" "0" "C:\\MyFile.txt" "MyFileType" "20200318" "MyAppID"
Application has the following logic:
SortedList<string, string> L = new SortedList<string,string>();
for (int i = 2; i <= args.GetLength(0) - 1; i++)
{
L.Add(args[i].Split(':')[0], args[i].Split(':')[1]);
}
List<SqlParameter> p = new List<SqlParameter>();
p.Add(new SqlParameter("@JobName", args[0]));
string xmlResult = D.RunProcedureXmlString("SPU_GetJobInfo", p);
So, when I hit the line inside of the loop on the first iteration, the following run time error happens:
args[i].Split(':')[1] 'args[i].Split(':')[1]' threw an exception of type 'System.IndexOutOfRangeException' string {System.IndexOutOfRangeException}
What is wrong with the existing logic and what is the solution?
I'm not sure if the fix will break what I guess worked before. Will need to test it later.