hey all,
let's say you have a delimited string value of
String value = val1,val2,val3;
and you do something like the following
String s = value.split(',')[3];
well this is outside the range of index, so how can i say if this does occur
just make it an empty string and proceed?
thanks,
rodchar
Jeroen Mostert - 26 Mar 2008 21:35 GMT
> hey all,
> let's say you have a delimited string value of
[quoted text clipped - 7 lines]
> well this is outside the range of index, so how can i say if this does occur
> just make it an empty string and proceed?
Test for it.
string[] values = value.split(',');
string s = values.Length > 3 ? values[3] : "";

Signature
J.
Ignacio Machin ( .NET/ C# MVP ) - 26 Mar 2008 22:08 GMT
> hey all,
> let's say you have a delimited string value of
[quoted text clipped - 10 lines]
> thanks,
> rodchar
What about by checking?
string[] parts = myStr.split( new char[]{','});
string d = ( index < parts.Length ) parts[index]: "";
if (
rodchar - 26 Mar 2008 23:16 GMT
thanks everyone for the help,
rod.
> hey all,
> let's say you have a delimited string value of
[quoted text clipped - 10 lines]
> thanks,
> rodchar