How can I add Multiple var in this code?
var trimChars = "ab";
sample I want to add:
"ab", "as", "Ab", "As"
is that possible?
further more heres some of my code:
if (e.KeyCode == Keys.Enter)
{
string Slb = lb.SelectedText.ToString();
var trimChars = "ab";
var trimmed = Slb.TrimStart(trimChars.ToCharArray());
rtb.SelectedText = trimmed;
lb.Hide();
}
thanks in advance and sorry for this newbie question :) .more power!
to remove strings from the start you can use :-
public string RemoveFromStart(string s, IEnumerable<string> strings )
{
foreach (var x in strings.Where(s.StartsWith))
{
return s.Remove(0, x.Length);
}
return s;
}
and use it like
var x = RemoveFromStart("ablah", new[] { "ab", "as", "Ab", "As" });
or with your code
var trimmed = RemoveFromStart(Slb, new string[] { "ab", "as", "Ab", "As" });