入力された文字列から特定の文字を除外するにはどうすればよいですか? 私がどのように試したかについては下記をご覧ください。どのようにC#のユーザー入力文字列から文字をフィルタにかけるには?
using System;
namespace PlainTest
{
class arrayTest
{
static void Main(string[] args)
{
bool doAlways = true;
int i = 1;
do
{
Console.WriteLine("Test Number : {0}", i++);
Console.Write("Key in the string: ");
char[] alpha = { 'a', 'b', 'c' };
string text = Console.ReadLine();
string filterAlphabet = text.Trim(alpha);
Console.WriteLine("The input is : {0}", text);
Console.WriteLine("Ater trimed the alpha a,b,c : {0}", filterAlphabet);
} while (doAlways == true);
}
}
}
しかし、私は数字の間にトリムされる文字で試してみました。フィルタが機能しません。異なる入力の出力については、以下を参照してください。
Test Number : 1
Key in the string: 123abc
The input is : 123abc
Ater trimed the alpha a,b,c : 123
Test Number : 2
Key in the string: abc123
The input is : abc123
Ater trimed the alpha a,b,c : 123
**Test Number : 3
Key in the string: aa1bb2cc3
The input is : aa1bb2cc3
Ater trimed the alpha a,b,c : 1bb2cc3**
Test Number : 4
Key in the string: aaabbbccc123
The input is : aaabbbccc123
Ater trimed the alpha a,b,c : 123
Test Number : 5
Key in the string: a12bc
The input is : a12bc
Ater trimed the alpha a,b,c : 12
Test Number : 6
Key in the string:
ご連絡ください。おかげさまで
cをあなたは[ドキュメント](https://msdn.microsoft.com/en-us/を読みましたライブラリ/ d4tt83f9(v = vs.110).aspx)の 'String.Trim'には? *現在のStringオブジェクトから、配列に指定された文字セットのすべての**先頭と末尾の**出現を削除します。*このドキュメントとこの問題に関する追加の参考文献が、大まかなGoogle検索で表示されます。次の質問をする前に、より多くの研究努力をしてください。 [Stack Overflowユーザーにどの程度の研究努力が期待されていますか?](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) – tnw