2017-10-04 15 views

答えて

3

あなたは、LINQを使用することができます。

if (StringName.Text.Any(Char.IsLetter)) 
{ 
    // Do something 
} 
+3

誰もあなたの前に、この答えに近いものを考え出すていないことを非常に奇妙な...たぶん、[別の宇宙](https://stackoverflow.com/a/12884682/477420 )... –

2

は、LINQのを試してみてください。あなたが任意ののUnicode文字、たとえば、ロシアъ受け入れる場合は、次の場合には

if (StringName.Text.Any(c => char.IsLetter(c))) 
{ 
    // Do Something 
} 

をあなただけa..zなどA..Zをしたい:

最後に
if (StringName.Text.Any(c => c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')) 
{ 
    // Do Something 
} 

、あなたが正規表現を主張する場合:

if (Regex.IsMatch(StringName.Text, @"\p{L}")) 
{ 
    // Do Something 
} 

または(2番目のオプション) a..zなどA..Z文字のみ

if (Regex.IsMatch(StringName.Text, @"[a-zA-Z]")) 
{ 
    // Do Something 
} 
関連する問題