验证字符串是否仅包含 C# 中的字母 - Verifying that a string contains only letters in C#

问题:

I have an input string and I want to verify that it contains:我有一个输入字符串,我想验证它是否包含:

  • Only letters or只有字母或
  • Only letters and numbers or只有字母和数字或
  • Only letters, numbers or underscore只有字母、数字或下划线

To clarify, I have 3 different cases in the code, each calling for different validation.澄清一下,我在代码中有 3 种不同的情况,每种情况都需要不同的验证。 What's the simplest way to achieve this in C#?在 C# 中实现这一目标的最简单方法是什么?


解决方案:

参考一: https://en.stackoom.com/question/4xL9
参考二: https://stackoom.com/question/4xL9
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章