I am convering VB code to c#:
Private Function SoundsLike(ByVal pWord As String,
Optional ByRef pAccuracy As Byte = 6) As String.
But I got different type of parameters. Let me know how can I write in C#.
I am convering VB code to c#:
Private Function SoundsLike(ByVal pWord As String,
Optional ByRef pAccuracy As Byte = 6) As String.
But I got different type of parameters. Let me know how can I write in C#.
On
VB.Net
Private Function SoundsLike(ByVal pWord As String, Optional ByRef pAccuracy As Byte = 6) As String
C#
private string SoundsLike(string pWord, byte pAccuracy = 6)
{
}
private string SoundsLike(string pWord, out byte pAccuracy)
{
}
Note that out and ref cant have a default values
FYI : "The out keyword causes arguments to be passed by reference. This is similar to the ref keyword, except that ref requires that the variable be initialized before being passed." Reference: http://geekswithblogs.net/ftom/archive/2008/09/10/c-and-the-difference-between-out-and-ref.aspx
The code like the following:
requires C# 4.0 because contains optional parameters. For earlier version the same can be achieved via overload.