
Originally Posted by
osadalakimdi
I want to trim all ComboBox items for example:
ComboBox items
Processor:12000
Ram:5000
I want to trim string before colon (including 'colon') and send to listbox, so i can calculate all prices for items.
So plz tell me how can i do that.
Thanks
use this
Code:
String data = "Processor:12000";
String result = data.substring(data.lastIndexOf(":")+1);
we substring the String. String.substring([b[This is the Start Index[/b])
so data.lastIndexOf(":") -> return the index of last : found in the string..
and return ":12000" but we need only "12000" so +1 for the index
update:
sorry i dont see that you want to calculate. so
try this code instead
Code:
int total=0;
foreach (String text in [your list].Items) {
total+= int32.Parse(text.Substring(text.LastIndexOf(":")+1));
}