我可以改进我的功能以不按每个元素搜索?
#Region " Font Is Installed? Function "
' [ Font Is Installed? Function ]
'
' Examples :
' MsgBox(Font_Is_Installed("Lucida Console"))
Private Function Font_Is_Installed(ByVal FontName As String) As Boolean
Dim AllFonts As New Drawing.Text.InstalledFontCollection
For Each Font As FontFamily In AllFonts.Families
If Font.Name.ToLower = FontName.ToLower Then Return True
Next
Return False
End Function
#End Region
更新:
好的,现在我看到了“.tolist”函数,现在我的代码是这样的:
Private Function Font_Is_Installed(ByVal FontName As String) As Boolean
Dim AllFonts As New Drawing.Text.InstalledFontCollection
Dim FontFamily As New FontFamily(FontName)
If AllFonts.Families.ToList().Contains(FontFamily) Then Return True Else Return False
End Function
我有同样的问题:第二种方法最好改进,还是我可以更好地改进它?