Link to home
Start Free TrialLog in
Avatar of RecipeDan
RecipeDan

asked on

Null Array

I have a value that I am splitting into an array. When the value is null, it gives me an error message. How can I prevent the error message when the value is null.
                        string PhoneNum = reader["PhoneNumber"].ToString();
                        string[] strArr = PhoneNum.Split('-');
                        PersonPhoneNumber1.Value = strArr[0];
                        PersonPhoneNumber2.Value = strArr[1];
                        PersonPhoneNumber3.Value = strArr[2];   

Open in new window

SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RecipeDan
RecipeDan

ASKER

Thank you both for your assistance.