驗證字符串是否僅包含 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章