【发布时间】:2019-08-09 13:20:34
【问题描述】:
我从这个链接获得了以下 C# 代码:How to prevent users from typing special characters in textbox
string allowedchar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
if (!TXT_NewPassword.Text.All(allowedchar.Contains))
{
// Not allowed char detected
}
以下代码是上述代码的vb.net版本
Dim allowedchar As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
If Not TXT_NewPassword.Text.All(allowedchar.Contains) Then
' Not allowed char detected
End If
我该如何解决这个错误? :https://prnt.sc/mzsmkd
错误信息:
重载解析失败,因为没有可访问的“包含”接受 这个参数的数量
【问题讨论】:
-
string.Contains是方法而不是属性。 geeksforgeeks.org/c-sharp-string-contains-method