string current1="02/02/1988";
string[] ar1=current1.Split('/');
string ar2=ar1[2];
I am getting error like this.Index was outside bounds of the array @last line
If i put same code in IIS
string current1="02/02/1988";
string[] ar1=current1.Split('/');
string ar2=ar1[2];
I am not getting any error
Could you please solve above problem?.
If i put this code as normal like this
string current1="02/02/1988";
string[] ar1=current1.Split('-');
string ar2=ar1[2];
sometimes i am getting error and sometimes not getting error
Loading

Selva GanapathyRank #560 · 4.3K reputationPosted Feb 24, 2014, 6:00 AM EST
Seems you are trying to get year seperated from in an DateTime formate. Why cant you try the following code snippet to achieve your requirement?
string ar2 = DateTime.Now.Year;
Regards,
Selva Ganapathy K
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 20, 2014, 9:32 PM EST
Sasi ReddyRank #4,458 · 342 reputationPosted Feb 20, 2014, 9:56 PM EST
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 20, 2014, 9:59 PM EST
Sasi ReddyRank #4,458 · 342 reputationPosted Feb 20, 2014, 10:04 PM EST
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 20, 2014, 10:41 PM EST
Sasi ReddyRank #4,458 · 342 reputationPosted Feb 20, 2014, 10:55 PM EST
string current1="02/02/1988";
string[] ar1=current1.Split('-');
string ar2=ar1[2];
and i am getting index was out of bounds of array
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 21, 2014, 12:00 AM EST
Sasi ReddyRank #4,458 · 342 reputationPosted Feb 21, 2014, 12:12 AM EST
VulpesRank #55 · 29.2K reputationPosted Feb 21, 2014, 12:50 AM EST
Sasi ReddyRank #4,458 · 342 reputationPosted Feb 21, 2014, 6:50 PM EST
VulpesRank #55 · 29.2K reputationPosted Feb 24, 2014, 5:44 AM EST
I'd try putting the break-point earlier in the code and then 'single step' from there to see if you can figure out if and why it's being by-passed.
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 24, 2014, 6:35 PM EST
hi,
I think, this problem of culture. It might be possible your separator is '-' and you are trying to split it by '/'...