For example
Removing "RT" from "ROBERT FROST" will give you "OBE FOS"
public static string RemoveCharacters(string s, string removeChars)
{
int i=0,j=0;
int lengthC = removeChars.Length;
int lengthS = s.Length;
int[] intCollection = new int[256];
char[] s2 = new char[lengthS];
for (i = 0; i < lengthC; i++)
{
intCollection[removeChars[i]] = 1;
}
i = j = 0;
for (i = 0; i < lengthS; i++)
{
if (intCollection[s[i]] != 1)
{
s2[j] = s[i];
j++;
}
}
return new string(s2);
}
No comments:
Post a Comment