Link to home
Start Free TrialLog in
Avatar of pkrish
pkrish

asked on

trying to expand range of characters specified in a list object

Hi all,
         I have a method called "get_range_alphabets(List lp)"

 I am passing a List object lp of type ('t,x-z,a')

 I want to get the output as ('a','t','x','y',z').
 The output list is in order and it expands on the range x-z.

 Can someone suggest a solution?

 Thanks for your help,

 pkrish
Avatar of Mick Barry
Mick Barry
Flag of Australia image

you can use the split() method of String to split on -
then use a loop to loop thru the chars

for (char c=startc; c<=endc;c++)
{
   // add c to result list
ASKER CERTIFIED SOLUTION
Avatar of arun_kuttz
arun_kuttz

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
How is your range specified, i.e. how do you know it's not just individual characters?
Avatar of pkrish
pkrish

ASKER


CEHJ,
         range is specified as one of the elements in the list "a-d" and that needs to be extracted and expanded along with the individual characters.

Arun kuttz's solution works fine for me.
Thanks kuttz and all.