akohan
asked on
question on C# and exception
Hello group,
I'm reading some input file (text) where I have to parse and tokenzie some data. In order to extract a field such as
applicant-id I have used:
trans.applicant_id = arData[x].Substring(0, 10);
which works fine as long as there is a valid value for applicant id in the text file like:
application id 0123456789
however, if I receive file without the value then I will run into exception error since I have put the code in a try/catch block.
What should I do (using if statement) in order not to get into exception when value doesn't exist.
Regards
try this
if(arData[x].Length >= 10)
{
trans.applicant_id = arData[x].Substring(0, 10);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window