Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
private string DateConvert(string dateformat)
        {
            string date = "";
            char[] sepe = new char[] { ' ' };
            string[] seped = new string[2];
            ArrayList TopUp = new ArrayList();
            ArrayList Remittence = new ArrayList();

            if (dateformat != null)
            {
                if (dateformat.IndexOf(sepe[0]) != -1)
                {
                    TopUp = new ArrayList(dateformat.Split(sepe));
                    date = Convert.ToString(TopUp[0]);
                    string[] darr;
                    darr = date.Split('-');
                    string dob1 = darr[1].ToString() + "/" + darr[0].ToString() + "/" + darr[2].ToString();
                    date = dob1;


                }
            }



error:- Index was outside the bounds of the array.
Posted
Updated 18-Aug-14 20:48pm
v3
Comments
Sergey Alexandrovich Kryukov 19-Aug-14 2:54am    
In what line?
—SA
Naveen Singh 19-Aug-14 2:55am    
string dob1 = darr[1].ToString() + "/" + darr[0].ToString() + "/" + darr[2].ToString();

1 solution

Use the debugger and you will see. For example, you use darr[1] assuming that this array has at least 2 elements. But why? date.Split can return you less, even 0 elements.

—SA
 
Share this answer
 
Comments
Naveen Singh 19-Aug-14 4:34am    
string[] darr;

have this empty data ?
Sergey Alexandrovich Kryukov 19-Aug-14 11:20am    
Use the debugger and you will see.
—SA
Naveen Singh 20-Aug-14 5:01am    
thnkx SA
Sergey Alexandrovich Kryukov 20-Aug-14 11:03am    
You are welcome.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900