Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

i know it's small issue, but i need your idea, i search many sites already but not able to find correct way,

i want to get selected values from listbox, then i want to pass that values like string concat,(means i want to convert all values in one string).

can anyone please help me to assist, thanks friends,:)

Best Regards
G.Renga
Posted

 
Share this answer
 
C#
//Below linq query concat all the selected item 
 string required =listBox1.SelectedItems.Cast<string>().Aggregate((a, b)=>a+b);
//Below linq query concat all the distinct selected item 
 string required =listBox1.SelectedItems.Cast<string>().Distinct().Aggregate((a, b)=>a+b);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900