c# - Substring with repeating character -


how substring sample combobox items

e11-143 - america           -->    america  jc - political theory       -->    political theory 

i tried this:

string test = combobox1.text.substring(combobox1.text.indexof('-') + 1).trim(); 

but result

e11-143 - america           -->    143 - america  jc - political theory       -->    political theory 

use lastindexof index of last occurrence of character:

string test = combobox1.text.substring(combobox1.text.lastindexof('-') + 1).trim(); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -