Want to concatenate all the items that are selected in my ListBox (SelectedItems). The list box is using a class (RegionModel) as a datadource.
I have this going in foreach loop, but I'd like to put this into a single line, if possible. What I have doesn't break, but it doesn't print, just the class name that the item represents.
namespace ProLimb.Models
{
public class RegionModel
{
public string Continent { get; set; }
public string Country { get; set; }
}
//TRYING TO GET TO WORK
Regions = string.Join("; ", lstRegions.SelectedItems.OfType<object>());
}
I figure I need to cast it, it doesn't seem to work.
The final output should look like: "North; East; South; West", but instead it comes out: ProLimb.Forms.RegionModel