Shi*_*lpa -1 c# vb.net vb.net-to-c#
我正在将VB代码转换为c#:
Private Function SoundsLike(ByVal pWord As String,
Optional ByRef pAccuracy As Byte = 6) As String.
Run Code Online (Sandbox Code Playgroud)
但我得到了不同类型的参数.让我知道如何用C#编写.
VB.Net
Private Function SoundsLike(ByVal pWord As String, Optional ByRef pAccuracy As Byte = 6) As String
Run Code Online (Sandbox Code Playgroud)
C#
private string SoundsLike(string pWord, byte pAccuracy = 6)
{
}
private string SoundsLike(string pWord, out byte pAccuracy)
{
}
Run Code Online (Sandbox Code Playgroud)
请注意,out并且ref不能使用默认值
FYI:"out关键字导致参数通过引用传递.这类似于ref关键字,除了ref要求在传递之前初始化变量." 参考:http://geekswithblogs.net/ftom/archive/2008/09/10/c-and-the-difference-between-out-and-ref.aspx
| 归档时间: |
|
| 查看次数: |
378 次 |
| 最近记录: |