我有一些代码用于使用函数在HyperLink上设置NavigateUrl属性:
hypExtErrorReporting.NavigateUrl = ErrorReportingURL()
Public Function ErrorReportingURL() As String
' create the url and returns it as a string
End Function
运行FxCop突出显示(amonst其他内容)CA1055 The name of a method contains "uri", "Uri", "urn", "Urn", "url", or "Url", and the method returns a string.
从概念上讲,这对我来说很有意义,如果函数返回url / uri然后返回一个uri而不是一个字符串。但这意味着我的代码变为
hypExtErrorReporting.NavigateUrl = ErrorReportingURL().ToString()
Public Function ErrorReportingURL() As Uri
' create the url and returns it as a string
End Function
为什么NavigateUrl采用字符串而不是uri?