有些时候经常要查询数组中是否包含某个元素,用array.indexof非常方便:
Function getSex(ByVal Lname As String, ByVal dicPath As
String)
Dim Sex As String = "男"
dicPath =
System.IO.Path.GetDirectoryName(dicPath)
Dim temp() As String =
System.IO.File.ReadAllLines(dicPath &
"\nameDic.txt", System.Text.Encoding.Default)
If Array.IndexOf(temp, Lname)
<> -1 Then
Sex =
"女"
Else
Sex =
"男"
End If
Return Sex
End Function