Tuesday, July 29, 2014

How can i remove/delete digits in the beginning of a string ?

You could just find the index of the dot and use the String.Substring method:



string s = "1. hello";
string t = s.Substring(s.IndexOf('.') + 1).Trim(); //= hello


private void FindRecursive(TreeNode treeNode)
{
foreach (TreeNode tn in treeNode.Nodes)
{
//tn.Text = "1. hello"
string x = tn.Text.Substring(tn.Text.IndexOf('.') + 1).Trim(); //= hello
if (x == this.txtNodeTextSearch.Text)
tn.BackColor = Color.Yellow;

FindRecursive(tn);
}
}




No comments:

Post a Comment