Question

string lbNames = String.Join(", ", (from ListItem li in lbName.Items where li.Selected select li.Value.ToString()).ToArray());

I have this code above that gathers selected item in an ListBox and separated them by names with a comma into one string value. e.g. Bob, Peter, Dick, James

How do I get the number of array I was able to get from the selected value? In this case 4.

Was it helpful?

Solution

int intArrayNum = lblNames.Length - lbNames.replace(",").Length
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top