splitting a string into a drop down

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a string of dates seperated by commas and I need to seperate them and
put them into a dropdown control. With the code below I am able to only
remove the comma which results in one big long string with no spaces and the
string is listed 5 time. How can I seperate the dates into seperate strings.

Here is the code I have so far:

string strDelim = ",";
char[] charDelim = strDelim.ToCharArray();
string Dates = StartDate;
string[] splitDates = null;

for (int x = 1; x <= 5; x++)
{
splitDates = Dates.Split(charDelim, x);
foreach (string s in splitDates)
{
SelectDate.Items.Add(s);
}
}

Thanks, Justin.
 
Is this what you want?

string[] splitDates = StartDate.Split(',');
for (int i = 0 ; i < splitDates.Length; ++i){
SelectDate.Items.Add(splitDates);
}

Karl
 
Back
Top